【发布时间】:2019-08-28 19:30:21
【问题描述】:
我的编译中有以下错误:
node_modules/@types/jest/index.d.ts(256,23): error TS1144: '{' or ';' expected.
node_modules/@types/jest/index.d.ts(258,9): error TS1005: '(' expected.
node_modules/@types/jest/index.d.ts(258,16): error TS1005: ')' expected.
node_modules/@types/jest/index.d.ts(278,26): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(278,50): error TS1005: ',' expected.
node_modules/@types/jest/index.d.ts(279,31): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(279,56): error TS1005: '(' expected.
node_modules/@types/jest/index.d.ts(279,62): error TS1005: ',' expected.
node_modules/@types/jest/index.d.ts(279,69): error TS1005: ')' expected.
node_modules/@types/jest/index.d.ts(280,31): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(280,57): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(280,60): error TS1109: Expression expected.
node_modules/@types/jest/index.d.ts(282,63): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(282,115): error TS1005: ',' expected.
node_modules/@types/jest/index.d.ts(284,60): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(284,104): error TS1128: Declaration or statement expected.
node_modules/@types/jest/index.d.ts(284,112): error TS1005: ',' expected.
node_modules/@types/jest/index.d.ts(404,32): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(404,33): error TS1003: Identifier expected.
node_modules/@types/jest/index.d.ts(912,11): error TS1005: '>' expected.
node_modules/@types/jest/index.d.ts(912,24): error TS1109: Expression expected.
node_modules/@types/jest/index.d.ts(912,39): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(912,40): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(912,42): error TS1128: Declaration or statement expected.
node_modules/@types/jest/index.d.ts(913,7): error TS1109: Expression expected.
node_modules/@types/jest/index.d.ts(914,22): error TS1005: ',' expected.
node_modules/@types/jest/index.d.ts(914,30): error TS1005: ':' expected.
node_modules/@types/jest/index.d.ts(914,74): error TS1005: '(' expected.
node_modules/@types/jest/index.d.ts(914,81): error TS1005: ')' expected.
node_modules/@types/jest/index.d.ts(929,30): error TS1005: ';' expected.
node_modules/@types/jest/index.d.ts(931,13): error TS1005: '(' expected.
node_modules/@types/jest/index.d.ts(931,20): error TS1005: ',' expected.
node_modules/@types/jest/index.d.ts(933,13): error TS1005: '(' expected.
node_modules/@types/jest/index.d.ts(934,5): error TS1005: ',' expected.
node_modules/@types/jest/index.d.ts(934,7): error TS1109: Expression expected.
node_modules/@types/jest/index.d.ts(935,10): error TS1005: ')' expected.
node_modules/@types/jest/index.d.ts(1128,1): error TS1128: Declaration or statement expected.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! SocleTechniqueClient@0.0.0 tsc-compile-client: `node ./node_modules/typescript/bin/tsc -p projects/framework/tsconfig.client.json`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the SocleTechniqueClient@0.0.0 tsc-compile-client script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我希望我的编译在没有此错误的情况下运行,但是我无法修复该错误,因为它是由于我的 typescript 版本 (2.7.1) 和输入文件的 jest 语法不兼容。
因此,我希望完全消除错误。一些研究引导我使用 --silent 选项,它实际上抑制了 npm ERR! errno 2 但我仍然得到 jest 输入的所有语法错误行。
这个post 建议在tsconfig 文件中添加一个"skipLibCheck": true,但它对我不起作用。
我正在寻找一种方法来抑制这些消息。
顺便说一句:
我的tsconfig 看起来像这样:
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"moduleResolution": "classic",
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"target": "es5",
"outDir": "../../build/",
"outFile": "../../build/framework-client.js",
"typeRoots": [
"node_modules/@types",
"../../node_modules/typescript/lib/lib.d.ts"
],
"types": ["jest"]
},
"files": [...]
}
【问题讨论】:
标签: typescript jestjs