Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version mismatch between tsc compiler and VS Code's language service

I just started playing with Visual Studio Code and when I created a new file called index.html, I am shown this warning message

A version mismatch between the globally installed tsc compiler (1.0.3.0) and VS Code's language service (1.8.10) has

Can someone please guide me what i have to do to fix this.

Is this serious or I can ignore. I googled but could not get much info

Thanks

enter image description here

like image 935
VivekDev Avatar asked Sep 15 '16 07:09

VivekDev


4 Answers

I added this to my settings.json file, accessed through preferences > Workspace Settings :

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

now I no longer receive this error and in the bottom right corner of my screen it shows the current version of Typescript that I have installed.

like image 166
Rarepuppers Avatar answered Oct 24 '22 12:10

Rarepuppers


[UPDATE] VS Code 1.6 now ships with TypeScript 2.0.3.

I just installed the latest Typescript, currently v.2.0.3, and installed VS Code v.1.5.3 on macOS Sierra. For some reason, exactly following the official doc didn't work for me.

Here's how I made it work:

After having installed the latest version globally: npm i -g typescript, I added the following line to my settings.json file (opened by cmd + ,):

"typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib",

Hope this helps someone else.

[update] as @ptpaterson mentioned on the comment below, on Windows the path is: "typescript.tsdk": "C:/Users/{user_name}/AppData/Roaming/npm/node_modules/typescript/lib/"

like image 42
rafaelbiten Avatar answered Oct 24 '22 10:10

rafaelbiten


You have to change the version of TypeScript that Visual Code is using to match the version you have installed:

https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions

The above is taken from the link:

If you want to use a newer version of TypeScript, you can define the typescript.tsdk setting (File > Preferences > User/Workspace Settings) pointing to a directory containing the TypeScript tsserver.js file.

You can find the installation location using npm list typescript, tsserver.js is usually under the lib folder.

For example:

{
    "typescript.tsdk": "node_modules/typescript/lib"
}
like image 11
andreasnauta Avatar answered Oct 24 '22 11:10

andreasnauta


You have to update your Typescript installation and restart Code afterwards:

npm install -g typescript

or

npm install -g [email protected]

The message should not longer appear, if it worked.

like image 9
kwood Avatar answered Oct 24 '22 12:10

kwood