当我将typescript从2.0.3升级到2.1.1时,得到错误:
[at-loader] Using typescript@2.1.1 from typescript and "tsconfig.json" from /Users/zhouweiming/data/project/iermu_opssite/src/tsconfig.json
/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:59508
throw e;
^
Error: Debug Failure. False expression: Unexpected node.
Verbose Debug Information: Node 94 (NullKeyword) was unexpected.
at Object.assert (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:3001:23)
at Object.Debug.failBadSyntaxKind (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:42746:55)
at serializeTypeNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44666:30)
at serializeTypeNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44637:56)
at serializeTypeOfNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44498:28)
at serializeParameterTypesOfNode (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44550:42)
at addOldTypeMetadata (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44425:136)
at addTypeMetadata (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44416:17)
at transformAllDecoratorsOfDeclaration (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44241:13)
at generateConstructorDecorationExpression (/Users/zhouweiming/data/project/iermu_opssite/src/node_modules/.typescript@2.1.1/lib/typescript.js:44351:40)
tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"inlineSources": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"lib": ["dom", "es6", "es2015"],
"rootDirs": ["./"],
"skipLibCheck": true,
"strictNullChecks": false,
"noUnusedParameters": false,
"noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types"
]
},
"files": [
"./public/*"
],
"compileOnSave": true,
"exclude": [
"node_modules/*",
"config/helpers.js",
"config/webpack.common.js",
"config/webpack.dev.js",
"config/webpack.prod.js",
"webpack.config.js",
"gulpfile.js"
]
}
other env
:
在我的项目中,当我在Class定义之前使用@Injectable()时,vscode输出错误:
[ts] Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
当我在所有代码中删除@Injectable()装饰器时,编译我的项目时所有错误都会消失,但在浏览器中运行失败,因为注入模块失败。