Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code ignores typescript version settings

I cannot get Visual Studio Code to update the version of typescript it is running.

I have read the answer to this question in detail.

I have tried setting my user settings to:

{
    "typescript.tsdk": "C:\\Users\\myUser\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"
}

This did not help.

I have also tried setting my workspace setting to:

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

This also seemed to have no effect.

I configured my task runner to run tasks.json and have it set to the following:

{
    "version": "0.1.0",
    "command": "tsc",
    "args": ["-v"],
    "echoCommand": true
}

This will call tsc with the -v command (to output the version).

When I press ctrl+shift+B the output reads

running command> tsc -v
Version 1.8.34

Is there something else I need to do to get Visual Studio Code to update its version of Typescript?

NOTE: I went to both of the paths I tried above and did a tsc -v in the bin folder and both returned 2.1.4

NOTE II: I have tried restarting Visual Studio Code several times.

NOTE III: When I run tsc -v from a command prompt from C: it outputs 2.1.4

I am running Visual Studio Code 1.8.1

Update:

I changed my tasks.json to run where tsc and this was the output:

running command> where tsc
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.js
C:\Users\myUser\AppData\Roaming\npm\tsc
C:\Users\myUser\AppData\Roaming\npm\tsc.cmd

So I can see where it is getting the older version of typescript from, but I don't understand WHY it is not using the "overridden" version.

My only guess is that the override is not for building. It is only for intelisense and such. Still, I need a way to change this...

like image 220
Vaccano Avatar asked Jul 20 '26 06:07

Vaccano


1 Answers

I work on TypeScript and JavaScript support in VSCode.

The typescript.tsdk sets the version of TypeScript used inside VSCode for IntelliSense. It does not impact which version of tsc used for running the tasks. The tasks use the same logic as the command line to resolve tsc.

To use your local copy of tsc in the task, change the task.json to:

{
    "version": "0.1.0",
    "command": "./node_modules/.bin/tsc",
    "args": ["-v"],
    "echoCommand": true
}

or, on windows:

{
    "version": "0.1.0",
    "command": ".\\node_modules\\.bin\\tsc.cmd",
    "args": ["-v"],
    "echoCommand": true
}

Hope that helps clear things up. Please let us know if have any ideas for making the documentation of this more clear, or you can even submit a PR to improve the docs.

like image 68
Matt Bierner Avatar answered Jul 21 '26 20:07

Matt Bierner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!