3

为什么这样做?我以为我可以正常工作,但是在编写了一些带有?.语法的代码后,它就停止了工作。我试图更新涉及的依赖项,但无济于事。

贝娄希望一切相关。(命令是npm run generate:nexus

包.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",
    ],
}

错误:

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)
4

1 回答 1

0

没有编译错误,错误是使用的节点不支持.?可选链接。

于 2021-07-27T15:03:58.077 回答