Visual Code: bogus error about decorators in Angular 2 TypeScript files

problem:

Visual Code displays bogus errors about using decorators in Angular 2 TypeScript files:

 @Component({ //problem: causes bogus error!  
  moduleId: module.id,  
  selector: 'app-basic-app',  
  templateUrl: 'app-basic.component.html',  
  styleUrls: ['app-basic.component.css']  
 })  
 export class AppBasicAppComponent { //problem: red lines appear here!  
  title = 'app-basic works!';  
 }  


solution 1:
add file jsconfig.json to the top level of the project:

 {  
   "compilerOptions": {  
     "target": "ES6"  
   }  
 }  

note: this turns ON the ES6 support for JS validation

solution 2:
turn OFF TypeScript validation in Visual Code.
but then you may need to write a Visual Code problemMatcher to parse the output from tsc ...

in .vscode/settings.json:

 "typescript.validate.enable": false  

Comments