Skip to content

Instantly share code, notes, and snippets.

@tonysneed
Created October 23, 2016 07:09
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tonysneed/bb6d442103a057578a9498f106e45ac5 to your computer and use it in GitHub Desktop.
Use Specific Version of TypeScript with VS Code

NOTE: These steps are only required if you want to use a version of TypeScript that is not the same as the version that is bundled with Visual Studio Code.

  • Install the latest version of TypeScript

    npm install -g typescript@version
    
  • Configure VS Code to use installed version of TypeScript by opening Preferences, User Settings.

    • Settings on Mac:
    {
        "typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib/"
    }
    • Settings on Windows - substitute {User Name}:
    {
        "typescript.tsdk": "c:\\Users\\{User Name}\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"
    }
    • Settings on Linux:
    {
        "typescript.tsdk": "/usr/lib/node_modules/typescript/lib/"
    }
@mariusschulz
Copy link

Might I suggest using a local install of TypeScript, rather than a global one? That way, if you're working on multiple projects, you can update the TypeScript versions independently:

@tonysneed
Copy link
Author

@mariusschulz For new projects by default I would probably want to use the version of TypeScript installed globally, because it might be higher than the version bundled with VS Code. If for a particular project I want to use a specific version (e.g. beta) of TypeScript, then I could always define typescript.tsdk in the workspace settings to point to the local copy, as described in your article. There is no harm in setting the version in user settings because the workspace will always override the global settings.

@deepaktatineni
Copy link

run npm root -g to know the path for global typescript path

@Evavic44
Copy link

Evavic44 commented Jan 4, 2024

Relative import worked for me on windows:

"typescript.tsdk": "/usr/src/app/blog-app/node_modules/typescript/lib"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment