在Visual Studio中使用特定的TypeScript编译器版本 [英] Use specific TypeScript compiler version in Visual Studio

查看:237
本文介绍了在Visual Studio中使用特定的TypeScript编译器版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以为Visual Studio中的项目设置特定的TypeScript编译器版本.因此,即使将发布新版本,我也可以将项目配置为始终使用1.0版.

I wonder if there's a way to set specific TypeScript compiler version for project in Visual Studio. So I could configure a project to always use version 1.0, even if new versions would be released.

我知道这不是之前是可能的,我想知道TypeScript成熟到1.0版后情况是否会发生变化.

I know it was not possible before and I wonder if things changes after TypeScript matured to 1.0 version.

我注意到,现在Visual Studio在项目文件中创建了<TypeScriptToolsVersion>0.9</TypeScriptToolsVersion>属性,但是找不到有关它的任何文档.

I noticed that now Visual Studio creates <TypeScriptToolsVersion>0.9</TypeScriptToolsVersion> property in a project file, but couldn't find any documentation about it.

推荐答案

如果尝试使用TypeScript 1.0版使用<TypeScriptToolsVersion>0.9</TypeScriptToolsVersion>编译项目,则会出现以下错误:

If you try to compile a project with <TypeScriptToolsVersion>0.9</TypeScriptToolsVersion> using TypeScript version 1.0 you'll get the following error:

您的项目文件使用的TypeScript编译器和工具的版本与本机上当前安装的版本不同.在C:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 0.9 \ tsc.exe中找不到编译器.您可以通过更改项目文件中的元素来解决此问题.

Your project file uses a different version of the TypeScript compiler and tools than is currently installed on this machine. No compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.9\tsc.exe. You may be able to fix this problem by changing the element in your project file.

因此它阻止您使用较新版本进行编译.但是,它不会使编译器进入0.9兼容模式.

So it's preventing you from compiling with newer version. It does not however put the compiler into some 0.9 compatibility mode.

但是,如果您安装了TypeScript 0.9,它将针对该版本进行编译.因此,可以的,您可以使用属性强制使用特定版本的TypeScript编译器.

But if you have TypeScript 0.9 installed, it will compile against that version. So yes, you can force a specific version of the TypeScript compiler using the attribute.

<TypeScriptToolsVersion>的基本作用是更改了编译器的路径:

Basically what the <TypeScriptToolsVersion> do is that it changes the path to the compiler:

C:\Program Files (x86)\Microsoft SDKs\TypeScript\<TypeScriptToolsVersion>\tsc.exe

这篇关于在Visual Studio中使用特定的TypeScript编译器版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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