typescript - 如何在 VSCode 中默认使用 settings.json 中定义的 TypeScript 版本?

标签 typescript visual-studio-code vscode-settings

要求:在 VSCode 中打开 TypeScript 文件时,使用来自 node_modules 的 TypeScript 版本,而不是 VSCode 的 TypeScript 版本

.vscode/settings.json 中,我添加了 documentation 中定义的以下设置:

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

然而,VSCode 仍然默认使用它的 typescript 版本。我在 vscode-typescript-default-version 中重现了这个问题存储库。

在 VSCode 中打开 TypeScript 文件时,默认使用来自 node_modules 的 TypeScript 版本需要做什么?

三极管

最佳答案

当你打开一个typescript文件后,点击vscode右下角的typescript版本,然后选择Use Workspace Version

enter image description here

如果您需要此配置作为 vscode 上所有 typescript 文件的默认配置,请将配置放在“用户设置”(ctrl+,) 上。

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

在我的例子中,我在 ~/.config/Code/User 中有这个文件。如果您在没有 node_modules/typesript/lib 的目录中打开文件,则会显示警告:

The path /home/jahuuar/test/node_modules/typescript/lib doesn't point to a valid tsserver install. Falling back to bundled TypeScript version.

关于typescript - 如何在 VSCode 中默认使用 settings.json 中定义的 TypeScript 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49949148/

相关文章:

reactjs - 类型 'schProd' 上不存在属性 '{} | { schProd: string; }'

html - 为什么我的 Visual Studio Code Live Server 在保存时跳转到页面的特定部分?

java - 调试器抛出 "Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp"错误

visual-studio-code - 如何在 vscode 中突出显示用户指定的单词

angular - 比较 Typescript/Angular 4 上的日期

javascript - 在 Angular 8 中查找数组中的所有重复项

visual-studio-code - 如何使用 JavaScript/Nodejs 在 VSCode 中显示警告、错误、函数、变量

macos - VSCode-如何在.Net Core 2.0+ API中管理用户 secret

angular - Ionic 3 - 运行时错误无法读取 null 的属性 'scrollToTop'

python - 默认情况下禁用输入停止?