在哪里可以找到 Visual Studio 中安装的 TypeScript 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23948348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 01:16:15  来源:igfitidea点击:

Where can I find the TypeScript version installed in Visual Studio?

visual-studiotypescript

提问by Adrian Rosca

Maybe it's obvious, but I checked everywhere (besides the right place) and googled it. Nothing.

也许这很明显,但我到处检查(除了正确的地方)并用谷歌搜索。没有。

回答by basarat

If you only have TypeScript installed for Visual Studio then:

如果您只为 Visual Studio 安装了 TypeScript,则:

  1. Start the Visual Studio Command Prompt
  2. Type tsc -vand hit Enter
  1. 启动Visual Studio 命令提示符
  2. 类型tsc -v和回车键


Visual Studio 2017 versions 15.3 and above bind the TypeScript version to individual projects, as this answer points out:

Visual Studio 2017 版本 15.3 及更高版本将 TypeScript 版本绑定到单个项目,正如这个答案所指出的

  1. Right click on the project node in Solution Explorer
  2. Click Properties
  3. Go to the TypeScript Build tab
  1. 右键单击解决方案资源管理器中的项目节点
  2. 单击属性
  3. 转到 TypeScript 构建选项卡

回答by Alex Fainshtein

Two years after the question was asked, using Visual Studio Command Promptstill did not produce right answer for me. But the usual Help|About window seems working these days:

在提出问题两年后,使用Visual Studio 命令提示符仍然没有为我提供正确的答案。但是现在通常的 Help|About 窗口似乎有效:

Snapshot of VS Community "About" dialog

VS 社区“关于”对话框的快照

UPDATE (June 2017):

更新(2017 年 6 月):

  1. VS 2013 does NOT show this info. (Later note: VS 2017 Enterprise edition does not show this info either).

  2. VS uses Microsoft Build Engine (MSBuild) to compile Typescript files. MSBuild can support several major releases of Typescript, but About window shows only the latest one.

  1. VS 2013 不显示此信息。(后记:VS 2017 企业版也不显示此信息)。

  2. VS 使用 Microsoft Build Engine (MSBuild) 来编译 Typescript 文件。MSBuild 可以支持几个主要版本的 Typescript,但关于窗口只显示最新的一个。

Here is how to get to the bottom of it:

以下是深入了解它的方法:

A. To check which versions of Typescript are installed with your Visual Studio/MSBuild, inspect contents of C:\Program Files (x86)\Microsoft SDKs\TypeScriptfolder. For example, I have versions 1.0, 1.8 and 2.2:

A. 要检查您的 Visual Studio/MSBuild 安装了哪些版本的 Typescript,请检查C:\Program Files (x86)\Microsoft SDKs\TypeScript文件夹的内容。例如,我有 1.0、1.8 和 2.2 版本:

Typescript versions as folder names

打字稿版本作为文件夹名称

B. Check which version of Typescript is requestedby your project. In *.csproj file, look for <TypeScriptToolsVersion> tag, or you can add it if it is missing, like this

B. 检查您的项目要求使用哪个版本的 Typescript 。在 *.csproj 文件中,查找 <TypeScriptToolsVersion> 标签,或者如果缺少可以添加它,像这样


<PropertyGroup> ... <TypeScriptToolsVersion>1.8</TypeScriptToolsVersion> ... </PropertyGroup>

C. Finally, you can check, which version of Typescript is actually usedby MSBuild. In TOOLS | Options | Projects and Solutions | Build and Runset MSBuild project output verbosityto Detailed:

C. 最后,您可以检查一下,MSBuild实际使用的是哪个版本的 Typescript 。在工具| 选项 | 项目和解决方案 | 生成并运行MSBuild 项目输出详细程度设置为详细

enter image description here

在此处输入图片说明

Then build your project and inspect the output: you should see the reference to one of Typescript folders described in (A).

然后构建您的项目并检查输出:您应该看到对 (A) 中描述的 Typescript 文件夹之一的引用。

回答by freedeveloper

Based in the response of basarat, I give here a little more information how to run this in Visual Studio 2013.

根据basarat的响应,我在这里提供了更多信息,如何在 Visual Studio 2013 中运行它。

  • Go to Windows Start button -> All Programs -> Visual Studio 2013 -> Visual Studio Tools A windows is open with a list of tool.
  • 转到 Windows 开始按钮 -> 所有程序 -> Visual Studio 2013 -> Visual Studio 工具 一个带有工具列表的窗口打开。

Menu path for Visual Studio Tools

Visual Studio 工具的菜单路径

  • Select Developer Command Prompt for VS2013
  • In the opened Console write: tsc -v
  • You get the version: See Image
  • 选择 VS2013 的开发人员命令提示符
  • 在打开的控制台中写入:tsc -v
  • 你得到版本:见图片

enter image description here

在此处输入图片说明

[UPDATE]

[更新]

If you update your Visual Studio to a new version of Typescript as 1.0.x you don't see the last version here. To see the last version:

如果您将 Visual Studio 更新为新版本的 Typescript 1.0.x,则您不会在此处看到最新版本。查看最新版本:

  • Go to: C:\Program Files (x86)\Microsoft SDKs\TypeScript, there you see directories of type 0.9, 1.0 1.1
  • Enter the high number that you have (in this case 1.1)
  • Copy the directory and run in CMD the command tsc -v, you get the version.
  • 转到:C:\Program Files (x86)\Microsoft SDKs\TypeScript,您会看到类型为 0.9、1.0 1.1 的目录
  • 输入您拥有的最高数字(在本例中为 1.1)
  • 复制目录并在CMD中运行命令tsc -v,你得到版本。

enter image description here

在此处输入图片说明

NOTE: Typescript 1.3 install in directory 1.1, for that it is important to run the command to know the last version that you have installed.

注意:Typescript 1.3 安装在目录 1.1 中,因此运行该命令以了解您安装的最新版本非常重要。

NOTE: It is possible that you have installed a version 1.3 and your code use 1.0.3. To avoid this if you have your Typescript in a separate(s) project(s) unload the project and see if the Typescript tag:

注意:您可能已经安装了 1.3 版并且您的代码使用了 1.0.3。为避免这种情况,如果您将 Typescript 放在单独的项目中,请卸载该项目并查看 Typescript 标签:

<TypeScriptToolsVersion>1.1</TypeScriptToolsVersion> 

is set to 1.1.

设置为 1.1。

[UPDATE 2]

[更新 2]

TypeScript version 1.4, 1.5 .. 1.7 install in 1.4, 1.5... 1.7 directories. they are not problem to found version. if you have typescript in separate project and you migrate from a previous typescript your project continue to use the old version. to solve this:

TypeScript 版本 1.4、1.5 .. 1.7 安装在 1.4、1.5... 1.7 目录中。他们对找到的版本没有问题。如果您在单独的项目中有打字稿并且从以前的打字稿迁移,您的项目将继续使用旧版本。解决这个问题:

unload the project file and change the typescript version to 1.x at:

卸载项目文件并将打字稿版本更改为 1.x:

  <TypeScriptToolsVersion>1.x</TypeScriptToolsVersion>

If you installed the typescript using the visual studio installer file, the path to the new typescript compiler should be automatically updated to point to 1.x directory. If you have problem, review that you environment variable Path include

如果您使用 Visual Studio 安装程序文件安装了打字稿,则新打字稿编译器的路径应自动更新为指向 1.x 目录。如果您有问题,请检查您的环境变量 Path 是否包含

C:\Program Files (x86)\Microsoft SDKs\TypeScript.x\

SUGGESTION TO MICROSOFT:-) Because Typescript run side by side with other version, maybe is good to have in the project properties have a combo box to select the typescript compiler (similar to select the net version)

对 MICROSOFT 的建议:-) 因为 Typescript 与其他版本并排运行,所以在项目属性中有一个组合框来选择 typescript 编译器(类似于选择网络版本)可能很好

回答by atconway

The tsc -vcommand run technicallyreads the TypeScript compiler version within the SDK directory set within the Windows Pathvariable. This doesn't necessarily reflect the latest version installed as the Pathvariable is notupdated with subsequent installations.

技术上讲,tsc -v运行命令会读取 Windows变量中设置的 SDK 目录中的 TypeScript 编译器版本。这不一定反映安装的最新版本,因为后续安装不会更新该变量。PathPath

The version that VS.NET uses to compile the TypeScript is what's in the project's configuration:

VS.NET 用于编译 TypeScript 的版本是项目配置中的版本:

<TypeScriptToolsVersion>1.5</TypeScriptToolsVersion>

<TypeScriptToolsVersion>1.5</TypeScriptToolsVersion>

To help explain this more in detail I created the following post which has the specifics on the TypeScript versions installed, and which version VS.NET uses to compile the TypeScript files.

为了更详细地解释这一点,我创建了以下帖子,其中详细介绍了安装的 TypeScript 版本,以及 VS.NET 用于编译 TypeScript 文件的版本。

Which Version of TypeScript is Installed and Which Version is Visual Studio Using?

安装了哪个版本的 TypeScript,Visual Studio 使用哪个版本?

I also added a feature request on Microsoft Connect to make viewing and switching the TypeScript targeted version in VS.NET easier. This isn't really a TypeScript feature request as much as it is a VS.NET IDE enhancement.

我还在 Microsoft Connect 上添加了一个功能请求,以便在 VS.NET 中查看和切换 TypeScript 目标版本更容易。这并不是真正的 TypeScript 功能请求,而是 VS.NET IDE 增强功能。

Allow switching TypeScript configured version from Project Properties IDE

允许从项目属性 IDE 切换 TypeScript 配置版本

回答by binary_fm

On Visual Studio 2015 just go to: help/about Microsoft Visual Studio Then you will see something like this:

在 Visual Studio 2015 上只需转到:help/about Microsoft Visual Studio 然后您将看到如下内容:

Microsoft Visual Studio Enterprise 2015 Version 14.0.24720.00 Update 1 Microsoft .NET Framework Version 4.6.01055

Microsoft Visual Studio Enterprise 2015 版本 14.0.24720.00 更新 1 Microsoft .NET Framework 版本 4.6.01055

...

...

TypeScript 1.7.6.0TypeScript for Microsoft Visual Studio

适用于 Microsoft Visual Studio 的TypeScript 1.7.6.0TypeScript

....

....

回答by Daniel

You can run it in NuGet Package Manager Console in Visual Studio 2013.

您可以在 Visual Studio 2013 的 NuGet 包管理器控制台中运行它。

回答by Rich N

The TypeScript team sorted this outin Visual Studio 2017 versions 15.3 and later, including the free Community edition.

TypeScript 团队在 Visual Studio 2017 版本 15.3 及更高版本中对此进行了整理,包括免费的社区版。

How to See Which TypeScript Versions are Installed in Visual Studio

如何查看 Visual Studio 中安装了哪些 TypeScript 版本

All you now need do is to go to project properties of any TypeScript Visual Studio project (right-click the project file in Solution Explorer/Properties), then go to the TypeScript Build tab on the left-hand side. This has a 'Typescript version' dropdown that shows you the version the project is using, and if you open it the dropdown shows you ALL versions of TypeScript currently installed in Visual Studio.

您现在需要做的就是转到任何 TypeScript Visual Studio 项目的项目属性(右键单击解决方案资源管理器/属性中的项目文件),然后转到左侧的 TypeScript Build 选项卡。它有一个“Typescript 版本”下拉列表,显示项目正在使用的版本,如果打开它,下拉列表会显示当前安装在 Visual Studio 中的所有 TypeScript 版本

The actual installs are currently at C:\Program Files (x86)\Microsoft SDKs\TypeScriptand then subfolders by version number, at least on Win10 on my computer. If you want to see the exact version (e.g. 2.8.3 rather than just 2.8) you can find the appropriate tsc.exein here and look at its properties (Details tab in right-click/Properties in File Explorer).

实际安装当前位于C:\Program Files (x86)\Microsoft SDKs\TypeScript然后按版本号划分的子文件夹中,至少在我的计算机上的 Win10 上。如果您想查看确切版本(例如 2.8.3 而不仅仅是 2.8),您可以tsc.exe在此处找到合适的版本并查看其属性(右键单击中的详细信息选项卡/文件资源管理器中的属性)。

How to Install Specific TypeScript Version

如何安装特定的 TypeScript 版本

If you want to install a specific version of TypeScript for Visual Studio, you can download older versions from the Details->Releasessection of the TypeScript SDK for Visual Studio 2017 Downloads page. You can verify that the version has been installed either with the 'Typescript version' dropdown in VS or inspecting the C:\Program Files (x86)\Microsoft SDKs\TypeScriptfolder.

如果要为 Visual Studio 安装特定版本的 TypeScript,可以从TypeScript SDK for Visual Studio 2017 下载页面详细信息->版本部分下载旧版本。您可以使用 VS 中的“Typescript 版本”下拉列表或检查文件夹来验证版本是否已安装。C:\Program Files (x86)\Microsoft SDKs\TypeScript

回答by Mohammad Dayyan

First, make sure you have the following address in your Environment VariablesPath

首先,请确保您的邮箱中有以下地址 Environment VariablesPath

C:\Program Files (x86)\Microsoft SDKs\TypeScript.0

Then open your Command Promptand type the following command:

然后打开你的Command Prompt并输入以下命令:

tsc -v

回答by callback

You can do npm list | grep typescriptif it's installed through npm.

npm list | grep typescript如果它是通过 npm 安装的,你可以这样做。

回答by ?erban Ghi??

I have VS2015 and I have to run a build with TypeScript 1.7, although I have 1.8 installed via npm install typescript -gthere are two ways (at least for me they worked):

我有 VS2015,我必须使用 TypeScript 1.7 运行构建,尽管我通过npm install typescript -g两种方式安装了 1.8 (至少对我来说它们有效):

  1. Go to your .projfile and add <TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>as up as possible. Rebuild, re-run. If it doesn't work try 2.
  2. Go to Control Panel -> System -> Advanced System Settings -> Enviroment Variables. Make sure you add your desired TypeScript version first: C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.7;C:\Users\serban\AppData\Roaming\npm
  1. 转到您的.proj文件并<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>尽可能添加。重建,重新运行。如果它不起作用尝试2。
  2. Control Panel -> System -> Advanced System Settings -> Enviroment Variables。确保首先添加所需的 TypeScript 版本:C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.7;C:\Users\serban\AppData\Roaming\npm

This will also affect your CLI:

这也会影响您的 CLI:

$ tsc -v
message TS6029: Version 1.7.5