也许这是显而易见的,但我到处检查(除了正确的地方),谷歌它。什么都没有。


当前回答

在命令提示符中,只需输入以下命令的1,然后按Enter:

tsc - v 或 tsc - version 或 tsc -版本

注意:请确保已将Typescript添加到环境变量path中 执行命令前,请先查看:如何设置环境 变量。

其他回答

As far as I understand VS has nothing to do with TS installed by NPM. (You may notice after you install TS using NPM, there is no tsc.exe file). VS targets only tsc.exe installed by TS for VS extension, which installes TS to c:\Program Files (x86)\Microsoft SDKs\TypeScript\X.Y. You may have multiple folders under c:\Program Files (x86)\Microsoft SDKs\TypeScript. Set TypeScriptToolsVersion to the highest version installed. In my case I had folders "1.0", "1.7", "1.8", so I set TypeScriptToolsVersion = 1.8, and if you run tsc - v inside that folder you will get 1.8.3 or something, however, when u run tsc outside that folder, it will use PATH variable pointing to TS version installed by NPM, which is in my case 1.8.10. I believe TS for VS will always be a little behind the latest version of TS you install using NPM. But as far as I understand, VS doesnt know anything about TS installed by NPM, it only targets whateve versions installed by TS for VS extensions, and the version specified in TypeScriptToolsVersion in your project file.

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

tsc -v命令在Windows Path变量的SDK目录集中读取TypeScript编译器版本。这并不一定反映安装的最新版本,因为Path变量没有随着后续安装而更新。

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

< TypeScriptToolsVersion > 1。5 < / TypeScriptToolsVersion >

为了更详细地解释这一点,我创建了下面的帖子,其中有关于安装的TypeScript版本的细节,以及VS.NET使用哪个版本来编译TypeScript文件。

TypeScript安装的版本和Visual Studio使用的版本?

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

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

打开一个(普通的,不是VS)命令提示符或PowerShell提示符。

tsc.exe - v tsc。cmd - v tsc - v

如果你安装了相同版本的TypeScript for Visual Studio并使用npm,以上三个命令的输出应该是相同的。

如果没有,请检查System PATH,查看在路径层次结构中的位置以及列出了哪个typescript目录。对于PowerShell用户,简单的方法是: $env:path split ';'

注意不要在System PATH变量中列出任何TypeScript目录或多个TypeScript目录。截至2017年6月9日,我的系统路径看起来是这样的(只有顶部的部分,在这种情况下这是最重要的): Ps >$env:path -split ';' C:\Windows\system32 C:\Windows C:\Windows\System32\Wbem C:\Windows\System32\ WindowsPowerShell \ \ v1.0 C:\Program Files (x86)\Microsoft sdk \TypeScript\2.3 C: \ nodejs \ C:\Users\ {username} \ AppData \ \ npm徘徊

注意,PATH中只包括2.3目录,而不是多个版本。

在这个问题被提出两年之后,使用Visual Studio命令提示符仍然没有为我提供正确的答案。但通常的帮助|关于窗口似乎工作这些天:

更新(2017年6月):

VS 2013没有显示这个信息。(稍后注意:VS 2017企业版也不显示此信息)。 VS使用Microsoft Build Engine (MSBuild)编译Typescript文件。MSBuild可以支持几个主要的Typescript版本,但是About窗口只显示最新的版本。

下面是深入了解问题的方法:

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

B.检查你的项目需要哪个版本的Typescript。在*。在csproj文件中,寻找<TypeScriptToolsVersion>标签,或者如果它没有,你可以添加它,就像这样

< PropertyGroup > ... < TypeScriptToolsVersion > 1。8 < / TypeScriptToolsVersion > ... < / PropertyGroup >

C.最后,你可以检查MSBuild实际使用的Typescript版本。在TOOLS |选项|项目和解决方案|构建和运行中将MSBuild项目输出详细信息设置为详细信息:

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