为什么 tsc -v 报告的版本与 VS Code 的状态栏不同? [英] Why does tsc -v report a different version than VS Code's Status Bar?

查看:29
本文介绍了为什么 tsc -v 报告的版本与 VS Code 的状态栏不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚我使用的是哪个版本的 TypeScript.在 VS Code 中,如果我在终端中运行 tsc -v,它会说我正在运行 1.0.3.0.但是,在 VS Code 的状态栏中,它说我正在运行 2.2.2.这些数字不应该是一样的吗?为什么会出现差异?

I am trying to figure out what version of TypeScript I am using. In VS Code, if I run tsc -v in the terminal, it says I'm running 1.0.3.0. However, in VS Code's status bar, it says I'm running 2.2.2. Shouldn't these numbers be the same? Why the discrepancy?

推荐答案

VSCode 包括其自己的 TypeScript 捆绑版本,但也能够使用在本地工作区中找到的 TypeScript 版本.如果你点击 VSCode 右下角的 TypeScript 版本,会弹出一些选项让你选择使用哪个版本的 TypeScript:

VSCode includes its own bundled version of TypeScript, but is also able to use the version of TypeScript found in the local workspace. If you click the version of TypeScript at the bottom-right of VSCode, some options will pop up which let you select which version of TypeScript to use:

此外,您可以将 VSCode 配置为默认使用新的全局版本的 TypeScript.VSCode 在其文档中提供了有关所有这些的更多信息:

Additionally, you can configure VSCode to use a new global version of TypeScript by default. VSCode provides more info about all this in their documentation:

要默认使用不同的 TypeScript 版本,请在您的用户设置中配置 typescript.tsdk 以指向包含 TypeScript tsserver.js 文件的目录.您可以使用 npm list -g typescript 找到 TypeScript 安装位置.tsserver.js 文件通常位于 lib 文件夹中.

To use a different TypeScript version by default, configure typescript.tsdk in your user settings to point to a directory containing the TypeScript tsserver.js file. You can find the TypeScript installation location using npm list -g typescript. The tsserver.js file is usually in the lib folder.

这篇关于为什么 tsc -v 报告的版本与 VS Code 的状态栏不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆