Angular 2 with errors in Sublime Text 3

I am trying to start a new project in Angular 2 on Windows based on the following repository: https://github.com/mgechev/angular2-seed

Everything works fine ( npm install , npm start , ...), except that Sublime Text 3 shows me some errors that are not present during the execution of the project.

Below are the steps that I followed:

 $ git clone https://github.com/mgechev/angular2-seed.git $ cd angular2-seed $ npm install 

Then I open the project with Sublime Text (with TypeScript package), and I encounter some errors / warnings in the code.

Error # 1

Classes with @Component decorators show the following error:

Experimental decorator support is a feature that may be changed in a future version. Set the parameter "experimentalDecorators" to remove this warning.

(it ignores the string "experimentalDecorators": true in tsconfig.json)

Error # 2

In src / client / app / about / about.component.ts, for example, in the line:

  moduleId: module.id, 

Sublime shows this error:

Cannot find the name 'module'.

tsconfig.json

 { "compilerOptions": { "target": "es5", "module": "commonjs", "declaration": false, "removeComments": true, "noLib": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "es2015", "dom"], "sourceMap": true, "pretty": true, "allowUnreachableCode": false, "allowUnusedLabels": false, "noImplicitAny": true, "noImplicitReturns": true, "noImplicitUseStrict": false, "noFallthroughCasesInSwitch": true, "typeRoots": [ "./node_modules/@types", "./node_modules" ], "types": [ "node" ] }, "exclude": [ "node_modules", "dist", "src" ], "compileOnSave": false } 

package.json

https://github.com/mgechev/angular2-seed/blob/27db8a19f70470f5110482df1a4debc1100ec347/package.json

Why do I have these 2 errors? I can develop, but it is not very nice.

+6
source share
3 answers

I solved my problem thanks to this link: https://github.com/Microsoft/TypeScript-Sublime-Plugin/issues/470

Summarizing:

  • Go to user settings (Ctrl + Shift + P> Settings: Settings)
  • Add the following line: "typescript_tsdk": "C:/...../npm/node_modules/typescript/lib", (with the appropriate link)
  • Restart Sublime Text
  • Check if it works in the about.component.ts file by pressing F12 when the cursor is on module.id
  • Enjoy it!
+18
source

I will add my results with the same problem.

I have this problem and fixed it using the method described above. But after I brought the frontend application to the file structure on the server side (I use the jar as my server engine), the problem reappears. I solved this by changing the tsc path from the system-wide to /frontend/node_modules/typescript/bin/tsc , namely the local version of typescript that I used in my project. This solved my problem - for now.

+1
source

I could not find the typescript file because it was intentionally disguised as "tsc", but mine was located in:

 C:\Users\Mike\AppData\Roaming\npm\node_modules\typescript\lib 

To find it, I ran the command:

 where tsc 
0
source

All Articles