alisabzevari alisabzevari - 3 months ago 49
TypeScript Question

How to config vscode to work with Typescript 2 RC?

I want to work with Typescript 2 RC (Actually v2.0.2) in VSCode. How can I configure my editor to work with that?

Note: I want to use npm based type declarations.

Answer

VS Code ships with a recent stable version of TypeScript. 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.

To install the latest TypeScript version, run:

npm install typescript@next

Tip: To get a specific TypeScript version, specify @version. For example for TypeScript 2.0, you would use

npm install typescript@2.0.0.

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"
}

The directory path can be absolute or relative to the workspace directory. By using a relative path, you can easily share this workspace setting with your team. Refer to this blog post for more details on how to install the nightly builds of TypeScript.

After setting typescript.tsdk, restart VS Code and the TypeScript version will be shown in the bottom right of the Status Bar when you open a JavaScript or TypeScript file.

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