gpt4 book ai didi

visual-studio - Visual Studio 2019 中的 TypeScript 版本不匹配

转载 作者:搜寻专家 更新时间:2023-10-30 20:38:06 25 4
gpt4 key购买 nike

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

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"

enter image description here

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

我错过了什么?

最佳答案

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

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

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

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

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

关于visual-studio - Visual Studio 2019 中的 TypeScript 版本不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55715763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com