Reputation: 12582
I am working on a basic Angular project with Visual studio code(Version 1.19.2) as my IDE.
The following piece of code is working fine but VSC doesn't seem to be happy about it.
It is showing error when i use new Date()
or JSON.stringify
But the end results are correct and the console prints fine.
How to remove this error from Visual studio code?
Update 1
Here are my dependencies
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular/cli": "~7.0.3",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
}
Upvotes: 4
Views: 5261
Reputation: 12582
My Visual studio code
was using Typescript v2.6.2
.
As mentioned by @Jai I updated the VSC's typescript version to match the Typescript version of my Angular project, which in my case was Typescript v3.1.1
.
To update the typescript version
Step 1. Simply click on the version displayed in the footer of your visual studio code.
Step 2. Then choose Use Workspace version.
You will be good to go.
PS: Special thanks to @Jai.
Upvotes: 12
Reputation: 3157
it works in a plain .js file for me in VSC.
I wonder if you have a TypeScript support extension, but somehow not a web or JavaScript support extension.
I would start with your VSC extensions and see if you can easily install one.
Upvotes: 0