【发布时间】:2017-12-30 15:38:24
【问题描述】:
我正在尝试为我的 Angular 应用程序集成 Karma 和 Jasmine,该应用程序目前位于 v4.1.3 和 TypeScript@2.3.0 并使用 @types。这个问题不是其他TS2304 错误的重复,因为我没有遇到'require'或'process'等问题......
当我运行 npm test 时,在一堆组件文件中出现以下错误,
Cannot find name '__metadata'.
Cannot find name '__decorate'.
Cannot find name '__extends'.
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib" : ["es2015.core", "es6", "es7", "dom"],
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"sourceMap": true,
"noEmitHelpers": true,
"allowJs" : true,
"types": [
"hammerjs",
"jasmine",
"jquery",
"lodash",
"moment",
"node"
],
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"node_modules",
"typings"
],
"awesomeTypescriptLoaderOptions": {
"resolveGlobs": true,
"forkChecker": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}
当我尝试搜索名称时,我在 .ts 文件中找不到它们。这个错误是从哪里产生的?它来自捆绑的js吗?
【问题讨论】:
-
它仍然是重复的。没有被发现的东西的名称不同是无关紧要的。如果一个问题是关于添加两个名为 C 和 D 的整数变量,它仍然是关于如何添加 A 和 B 的同一个问题的重复;并没有因为变量名不同而不同。
标签: javascript angular typescript webpack typescript-typings