tsc 不检测 Angular2 RC 定义
tsc doesn't detect Angular2 RC definitions
我正在使用 angular 2.0.0-rc.1,但我正在努力使用 typescript 编译器 (Typescript 1.8.10).如果我在我的项目上 运行 tsc,我会收到大量这样的错误:
app/app.component.ts(1,33): error TS2307: Cannot find module '@angular/core'
但是,我认为因为 node_modules/@angular/core 中的 package.json
有一行:
"typings": "index.d.ts",
和index.d.ts
提供了定义,这不应该是这样吗? VSCode 不会突出显示这些包的任何问题,如果我在导入上单击 "Go to Definition",将 link 直达源代码。
我应该怎么做才能避免这样的编译器错误?
更新:
我的packages.json
:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true
},
"exclude": [
"node_modules",
"platforms"
]
}
在您的 tsconfig.json
排除 node_modules
文件夹中
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"noEmitOnError": true,
"noImplicitAny": false,
"removeComments": false,
"sourceMap": true,
"target": "es6",
"moduleResolution": "node",
"suppressImplicitAnyIndexErrors": true,
"watch":true
},
"compileOnSave": true,
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts",
"typings"
]
}
我正在使用 angular 2.0.0-rc.1,但我正在努力使用 typescript 编译器 (Typescript 1.8.10).如果我在我的项目上 运行 tsc,我会收到大量这样的错误:
app/app.component.ts(1,33): error TS2307: Cannot find module '@angular/core'
但是,我认为因为 node_modules/@angular/core 中的 package.json
有一行:
"typings": "index.d.ts",
和index.d.ts
提供了定义,这不应该是这样吗? VSCode 不会突出显示这些包的任何问题,如果我在导入上单击 "Go to Definition",将 link 直达源代码。
我应该怎么做才能避免这样的编译器错误?
更新:
我的packages.json
:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true
},
"exclude": [
"node_modules",
"platforms"
]
}
在您的 tsconfig.json
排除 node_modules
文件夹中
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"noEmitOnError": true,
"noImplicitAny": false,
"removeComments": false,
"sourceMap": true,
"target": "es6",
"moduleResolution": "node",
"suppressImplicitAnyIndexErrors": true,
"watch":true
},
"compileOnSave": true,
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts",
"typings"
]
}