Visual Studio 2017找不到TypeScript编译器?

5

我正在尝试在Visual Studio中构建一个使用TypeScript的应用程序。我按照这里的说明安装了项目所需版本(2.2)的TypeScript编译器,并使用NPM进行了安装。

npm install typescript 

我通过以下方式验证了我的安装:

tsc --version

然后它返回了

Version 2.2.2

应该是这样的。但是,当我尝试构建我的解决方案时,我一直收到以下错误信息:

Your project specifies TypeScriptToolsVersion 2.2, but a matching compiler was not found. The latest available TypeScript compiler will be used (2.3). To remove this warning, install the TypeScript 2.2 SDK or update the value of TypeScriptToolsVersion.

我已经试过在 Google 上搜索,但没有发现任何解决方案。有人能指点我一下该如何解决吗?

1个回答

4

您是否使用的是较旧版本的Visual Studio 2017?请确保您使用的是15.3版本。

15.2版本包含TypeScript 2.2,但15.3版本还允许选择每个项目不同版本的TypeScript。

更新后,您应该能够进入项目的“属性/TypeScript构建”,并确保选择了2.2版本。

对于未来的TypeScript更新,您可以安装Visual Studio 2017的TypeScript SDK

有关详细信息,请参见https://github.com/Microsoft/TypeScript/wiki/Updating-TypeScript-in-Visual-Studio-2017。(您所提到的说明适用于Visual Studio Code。)


您可能还需要安装 Microsoft.TypeScript.MSBuild nuget 包,您应该选择与您正在构建的 TypeScript 版本相匹配的包版本。 - AaronLS

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接