Visual Studio 2019 中的 TypeScript 版本不匹配 [英] TypeScript version mismatch in Visual Studio 2019

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

问题描述

我对 Typescript 版本控制感到非常困惑,因为它与 Visual Studio 2019 相关.我有一个使用 Typescript 的 .NET Core 2.2.x 项目.当我编辑任何 .ts 文件时,我收到以下警告(在错误列表中):

I am thoroughly confused by Typescript versioning as it relates to Visual Studio 2019. I have a .NET Core 2.2.x project which utilizes Typescript. When I edit any .ts file, I get the following warning (in the error list):

您的项目是使用 TypeScript 3.4 构建的,但 Visual Studio 当前使用的 TypeScript 语言服务版本是 3.4.3.您的项目可能正在使用 TypeScript 语言功能,在使用此版本的 TypeScript 编译器进行编译时会导致错误.要消除此警告,请安装 TypeScript 3.4.3 SDK 或更新项目属性中的 TypeScript 版本.

Your project is built using TypeScript 3.4, but the TypeScript language service version currently in use by Visual Studio is 3.4.3. Your project may be using TypeScript language features that will result in errors when compiling with this version of the TypeScript compiler. To remove this warning, install the TypeScript 3.4.3 SDK or update the TypeScript version in your project's properties.

它声称我的项目是使用 TypeScript 3.4 构建的,但 package.json 专门列出了 "typescript": "3.4.3".

It claims that my project is built using TypeScript 3.4, but package.json specifically lists "typescript": "3.4.3".

然后它要求安装 TypeScript SDK 3.4.3,我从 这里.我之前也 npm install -g typescript,所以运行 tsc -v 会产生 Version 3.4.3.

Then it asks to install TypeScript SDK 3.4.3, which I have from here. I also npm install -g typescript previously, so running tsc -v yields Version 3.4.3.

我错过了什么?

推荐答案

我遇到了与您描述的类似的问题,但在 Task Runner Explorer 中.

I had a similar problem as you describe but in the Task Runner Explorer.

假设:TypeScript 应该在您的 PATH 变量中(您可以通过从普通命令提示符运行 'tsc -v' 来检查.

Assumptions: TypeScript is should be in your PATH variables (you can check by running 'tsc -v' from a normal command prompt.

很长一段时间以来,Visual Studio 允许您选择要在每个项目基础上使用的 TypeScript 版本(右键单击项目 => 属性 => 选项卡Typescript Build").在这里,您可以选择正式安装的版本,也可以选择使用最新可用的".

Since quite a while, Visual Studio allows you to choose the TypeScript version to use on a per-project basis (right-click project => Properties => tab 'Typescript Build'). Here you could choose an officially installed version but also 'Use latest available'.

在 Visual Studio 选项中,您可以指定在使用 3rd 方工具构建 Web 项目时使用外部 Web 工具"的位置和顺序.在该列表中,您可能会找到一个项目$(PATH)".我把它移到了列表的顶部,这使得在搜索时首先找到全局安装的 TypeScript 版本.

In Visual Studio Options you can specify the locations and order in which 'External Web Tools' are used when building web projects using 3rd party tools. In that list, you will probably find an item '$(PATH)'. I moved it to the top of the list, which makes the globally installed TypeScript version the first to be found when searching for it.

我希望这也适用于您的情况.

I hope this applies for your situation as well.

这篇关于Visual Studio 2019 中的 TypeScript 版本不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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