VSCode Typescript Extension
Make sure you are using the right typescript version.
Typescript extension can use its own version instead of using your project’s typescript version which is set in package.json
- Open a JavaScript or TypeScript file in VS Code.
- In the VS Code command palette (F1 is the shortcut by default), run the TypeScript: Select TypeScript version command.
- Make sure you have
Use workspace version
selected
If there is no Use workspace version
option
Make sure you have typescript
in your dependencies in package.json
and you have installed your dependencies by using npm install
or npm clean-install
If you still do not have it – add typescript.enablePromptUseWorkspaceTsdk: true
to .vscode/settings.json
or find setting Enable Prompt Use Workspace Tsdk
and enable it
Recomendation
Setup typescript extension to prompt you whether to use workspace version
Find setting ‘Typescript: Enable Prompt Use Workspace Tsdk’ in VsCode settings and enable it
In the next time you open your workspace in VsCode you will see this notification:
You want to click “Allow” 🙂
Other Possible Solutions
- Update npm version
If you use nvm –nvm install --latest-npm
- Update nodejs version
If you are unable to update nodejs at the moment to the latest version you can update it to atlest the latest minor+path version (x.latest.latest
) to not have breaking changes - Remove
node_modules
andnpm install
- if you have project separated by folders and it is situated inside of those, you are unable to select typescript version in vscode. In that case open new vscode and go directly into your folder with package.json. (https://stackoverflow.com/users/5246617/pavol-travnik)