George Edwards
George Edwards

Reputation: 9229

tsc doesn't detect Angular2 RC definitions

I am using angular 2.0.0-rc.1, but am struggling with the typescript compiler (Typescript 1.8.10). If I run tsc on my project, I get loads of errors like this:

app/app.component.ts(1,33): error TS2307: Cannot find module '@angular/core'

However, I thought that because the package.json in node_modules/@angular/core has the line:

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

and index.d.ts provides the definitions, this shouldn't be the case? VSCode doesn't highlight any issues with these packages and will link through to the source if I click "Go to Definition" on the imports.

What should I do to avoid compiler errors like this?

Update:

My packages.json:

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

Upvotes: 0

Views: 63

Answers (1)

null canvas
null canvas

Reputation: 10613

In your tsconfig.json exclude node_modules folder

    {
      "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"
      ]
    }

Upvotes: 0

Related Questions