tsc不检测Angular2 RC定义

时间:2016-06-23 14:34:49

标签: typescript angular tsc

我正在使用angular 2.0.0-rc.1 ,但我正在努力使用typescript编译器(Typescript 1.8.10 )。如果我在我的项目上运行tsc,我会收到大量错误:

  

app / app.component.ts(1,33):错误TS2307:找不到模块'@ angular / core'

但是,我认为这是因为node_modules / @ angular / core中的package.json有以下行:

  "typings": "index.d.ts",

index.d.ts提供了定义,情况应该不是这样吗? VSCode没有突出显示这些包的任何问题,如果我点击导入上的“转到定义”,它将链接到源。

我应该怎么做才能避免像这样的编译器错误?

更新

我的packages.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": true
    },
    "exclude": [
        "node_modules",
        "platforms"
    ]
}

1 个答案:

答案 0 :(得分:0)

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"
      ]
    }
相关问题