也许这是显而易见的,但我到处检查(除了正确的地方),谷歌它。什么都没有。
当前回答
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.
其他回答
在命令提示符中,只需输入以下命令的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.
基于basarat的响应,我在这里给出了更多关于如何在Visual Studio 2013中运行它的信息。
进入Windows开始按钮->所有程序-> Visual Studio 2013 -> 打开Visual Studio Tools窗口,并显示工具列表。
选择VS2013的开发人员命令提示符 在打开的控制台中写入:tsc -v 你得到的版本:见图片
(更新)
如果你把你的Visual Studio更新到Typescript的新版本1.0。你在这里看不到最后的版本。查看最后的版本:
转到:C:\Program Files (x86)\Microsoft SDKs\TypeScript,在那里你会看到类型为0.9,1.0 1.1的目录 输入您拥有的较大的数字(在本例中为1.1) 复制目录并在CMD中运行tsc -v命令,您将得到 的版本。
注意:Typescript 1.3 install在目录1.1中,因此运行命令来了解你安装的最后一个版本是很重要的。
注意:有可能您已经安装了1.3版本,而您的代码使用1.0.3。为了避免这种情况,如果你的Typescript在一个单独的项目(s)卸载项目,看看Typescript标签:
<TypeScriptToolsVersion>1.1</TypeScriptToolsVersion>
设置为1.1。
(更新2)
TypeScript版本1.4,1.5 ..1.7安装在1.4,1.5…1.7的目录。他们不是问题的发现版本。如果你在一个单独的项目中有typescript,并且你从以前的typescript迁移,你的项目继续使用旧版本。要解决这个问题:
卸载项目文件并将typescript版本更改为1。x:
<TypeScriptToolsVersion>1.x</TypeScriptToolsVersion>
如果使用visual studio安装文件安装typescript,那么新的typescript编译器的路径应该自动更新为指向1。x目录。如果你有问题,检查你的环境变量Path包含
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.x\
给微软的建议:-)因为Typescript是和其他版本一起运行的,所以最好在项目属性中有一个组合框来选择Typescript编译器(类似于选择net版本)
你可以做npm list | grep typescript,如果它是通过npm安装的。
打开一个(普通的,不是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的私有字段生成快捷方式?
- 从元组/数组值派生联合类型
- 如何在Angular2 ngSwitch语句中使用typescript enum值
- 为什么Visual Studio 2015/2017/2019测试运行器没有发现我的xUnit v2测试
- Visual Studio复制项目
- 找到合成属性@panelState。请在您的应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。
- Angular 2+和debounce
- 如何在iis7应用程序池中设置。net Framework 4.5版本
- 在TypeScript箭头函数中指定返回类型
- 如何使用jQuery与TypeScript
- Angular 2模板中的标签是什么意思?
- Typescript接口-可能使“一个或另一个”属性要求?
- 如何扩展/继承组件?
- Visual Studio - Resx文件默认“内部”为“公共”
- 在Visual Studio 2010中有快速查找文件的方法吗?