5

I'm working on an Angular2-Typescript application. I've generated the project with angular-cli as follows:

ng new myApp

but when I create a new component, a warning appears on @Component tag.

I've tried to solve following this post:

Experimental decorators warning in Visual Studio Code

but does not work for me.

I attach my tsconfig.json:

{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es6",
"typeRoots": [
  "../node_modules/@types"
  ]
 }
}

Typescript version is : "typescript": "2.0.2"

Community
  • 1
  • 1
Samuel Fraga Mateos
  • 583
  • 1
  • 7
  • 21
  • Possible duplicate of [VSCode: Is it possible to supress experimental decorator warnings](http://stackoverflow.com/questions/31737677/vscode-is-it-possible-to-supress-experimental-decorator-warnings) – Wosi Sep 30 '16 at 08:52
  • @Wosi not works for me :( – Samuel Fraga Mateos Sep 30 '16 at 09:15
  • None of these answers? Did you give the first three answers a chance? – Wosi Sep 30 '16 at 09:17
  • This one works as long as you have TypeScript installed as part of your dependencies: http://stackoverflow.com/a/38970591/616304 Also, try specifying TypeScript 2.0.0 exactly as opposed to ^2.0.3 – Stephen Wilson Sep 30 '16 at 09:19
  • @StephenWilson if I use TypeScript 2.0.0 version I get the following error when I try to do `ng serve`: ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'directoryExists' of undefined – Samuel Fraga Mateos Sep 30 '16 at 09:30
  • Are you using angular-cli? If so try adding "awesome-typescript-loader": "2.2.1" to your package.json and re-run an npm install – Stephen Wilson Sep 30 '16 at 09:54
  • 1
    I use to get the error all the time with VSCode (only with projects where the tsconfig wasn't at the root of the project). Maybe in the last few weeks after accepting all the automatic updates, the problem finally went away. Maybe you just need an upgrade :-) – Paul Samsotha Sep 30 '16 at 10:18

1 Answers1

1

Finally, I solved my problem as follows:

First, updating typescript version:

$ npm install typescript@next

and then, editing user preference in vscode, adding the following:

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

Thanks to peeskillet :)

Community
  • 1
  • 1
Samuel Fraga Mateos
  • 583
  • 1
  • 7
  • 21
  • 2
    Explanation: You have to instruct your *VSCode* to use a TypeScript lib out of your *node* dependencies - not the built-it one. – Yuri Sep 30 '16 at 16:10