3

Why does it do that? I thought I had it working, but after writing some code with ?. syntax in it, it stopped working. I tried to update involved dependencies but to no avail.

Bellow is hopefully everything relevant. (Command is npm run generate:nexus)

package.json

{
  "name": "rita",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    ...
    "generate:nexus": "ts-node --transpile-only --project=./apps/server/tsconfig.nexus.json ./apps/server/src/nexus-prisma/schema.ts"
  },
  "dependencies": { ... },
  "devDependencies": { 
    ...
    "ts-node": "~9.1.0"
  },
}

tsconfig.nexus.json

{
    "extends": "./tsconfig.json",
    "compilerOptions": {
        "baseUrl": ".",
        "module": "CommonJS",
        "target": "esnext",

        "outDir": "dist",
        "rootDir": "src",
        "lib": ["esnext"],
        "esModuleInterop": true,
        "strict": true,
        "typeRoots" : [
            "node_modules/@types",
            "./src/nexus-prisma/nexus.generated.ts",
        ],

        //"extendedDiagnostics": true,
        //"noEmit": true,
    },
    "files": [
        "./src/nexus-prisma/schema.ts",
    ],
}

Error:

ts-node --transpile-only --project=./apps/server/tsconfig.nexus.json ./apps/server/src/nexus-prisma/schema.ts        

C:\project\apps\server\src\nexus-prisma\auth\maps.ts:47
            districts: helpers_1.sanitizeParamList(query, 'f-d')?.map(v => +v),
                                                                 ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:1072:16)
    at Module._compile (internal/modules/cjs/loader.js:1122:27)
    at Module.m._compile (C:\project\node_modules\ts-node\src\index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Object.require.extensions.<computed> [as .ts] (C:\project\node_modules\ts-node\src\index.ts:1059:12)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\project\apps\server\src\nexus-prisma\schema\carriers-of-offer\offer.ts:2:1)
Akxe
  • 9,694
  • 3
  • 36
  • 71
  • 2
    try changing `target` to `es2019` or `es2020` – Chase Jan 05 '21 at 06:27
  • 1
    References [here](https://github.com/TypeStrong/ts-node/issues/906), [here](https://github.com/TypeStrong/ts-node/issues/909). and [here](https://github.com/TypeStrong/ts-node/issues/903). Same answer on all of them – Chase Jan 05 '21 at 06:29
  • 7
    tldr; It is not TS error but a runtime nodeJS error. The target must be `es2019` or lower. – Akxe Jan 05 '21 at 06:59

1 Answers1

0

There were no compiling errors, the error was that the node used did not support .? optional chaining.

Akxe
  • 9,694
  • 3
  • 36
  • 71