TypeScript repos stuck on es2019

I can’t use modern javascript features in TypeScript repos. If I attempt to use es2020 or esnext I get errors setting up the workspace. This prevents me from using any libraries that include things like null coelessing operators and other modern language features. Below is a sample error that is triggered by ??.

{
 "errorCode": "INVALID_ARGUMENT",
 "errorInstanceId": "a24688dd-7e0d-4051-9928-41473fd32854",
 "errorName": "Functions:CompileFailed",
 "parameters": {
  "stdout": "./node_modules/xstate/dist/xstate.esm.js 276:42\nModule parse failed: Unexpected token (276:42)\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\n|         systemId\n|       } = invokeConfig;\n>       const resolvedId = invokeConfig.id ?? createInvokeId(this.id, i);\n|       const resolvedSrc = typeof src === 'string' ? src : xstate.invoke.${createInvokeId(this.id, i)};\n|       return {\n @ ./src/machines/SemanticSearch.ts 4:17-34\n @ ./src/machines/index.ts\n @ ./src/SemanticSearch.ts\n @ ./src/index.ts\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/src/machines/SemanticSearch.ts\n./src/machines/SemanticSearch.ts 34:21-80:5\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/src/machines/SemanticSearch.ts(34,22)\n      TS2554: Expected 0 arguments, but got 1.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(54,21)\n      TS1139: Type parameter declaration expected.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(54,27)\n      TS1005: ';' expected.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(54,35)\n      TS1128: Declaration or statement expected.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(54,409)\n      TS1005: ')' expected.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(54,411)\n      TS1434: Unexpected keyword or identifier.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(54,418)\n      TS1128: Declaration or statement expected.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(54,420)\n      TS1128: Declaration or statement expected.\n/scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts\n[tsl] ERROR in /scratch/standalone/c9a57dae-5339-4ada-ac2e-73e7fb776683/code-assist/contents/functions-typescript/node_modules/xstate/dist/declarations/src/setup.d.ts(55,1)\n      TS1128: Declaration or statement expected.",
  "stderr": ""
 }
}

If there is a workaround, let me know.

1 Like

Hi @CodeStrap ,

This is a limitation of the TypeScript functions Webpack configuration, which uses Webpack 4. We are in the process of upgrading repositories to Webpack 5, which supports newer language features like nullish coalescing. We expect to start rolling out the upgrade in the coming weeks.

3 Likes

TypeScript repositories now support Webpack 5, which you can gain access to by upgrading your master branch to the latest version in authoring. Please let us know if you run into any more issues.