Thierry Templier
Thierry Templier

Reputation: 202326

Errors when transpiling ts files for an Angular2 application

I try to use TypeScript with Angular. For this, I transpile my ts files using the tsc command and I have some errors. That said, the files are actually transpiled into JavaScript and I can make work my application but these errors are a bit strange....

Here is what I have:

app.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
app.ts(1,42): error TS2307: Cannot find module 'angular2/angular2'.
app.ts(13,7): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.

Here is the content of the tsd.json file:

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "angular2/angular2.d.ts": {
      "commit": "78ba6e41543e5ababbd1dda19797601be3c1f304"
    }
  }
}

Here is the content of the tsdconfig.json file:

{
  "compilerOptions" : {
    "emitDecoratorMetadata": true,
    "module": "commonjs",
    "target": "es5"
  },
  "files" : [
    "app.ts",
    "typings/angular2/angular2.d.ts"
  ]
}

To compile, I execute the command: tsc --watch *.ts. My ts files are located at the root of my project.

Thanks very much for your help, Thierry

Upvotes: 0

Views: 333

Answers (1)

Eggy
Eggy

Reputation: 4174

First, if you specify file(s) in tsc command, tsconfig.json file is ignored. You can learn more about it here. So you should invoke command: tsc -w. Second, you do not have to include typings in your files, they are just for intellisense in your editor(and angular2 includes its typings by default).

Upvotes: 1

Related Questions