typescript 错误:打字稿功能 1.5。当前语言水平为 1.4

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32277413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:46:42  来源:igfitidea点击:

Error: Typescript Feature 1.5. Current language level is 1.4

typescriptvisual-studio-2015

提问by brando

I am working in the context of Visual Studio 2015 (with Resharper), and am referencing a TypeScript definitions file for NodeJS. I have 3 other VS projects that are using node.d.tswithout problems. In this new project, however, I now have 146 errors saying the same thing:

我在 Visual Studio 2015(使用 Resharper)的上下文中工作,并且正在引用 NodeJS 的 TypeScript 定义文件。我还有其他 3 个 VS 项目都可以正常使用node.d.ts。然而,在这个新项目中,我现在有 146 个错误,说明同样的事情:

"Typescript Feature 1.5. Current language level is 1.4".

“打字稿功能 1.5。当前语言级别为 1.4”。

For the life of me, I can't figure out how to tell Visual Studio (or Resharper?) to use the latest TypeScript language version.

对于我的一生,我不知道如何告诉 Visual Studio(或 Resharper?)使用最新的 TypeScript 语言版本。

I've tried: Tools > Options > Typescript > Project > General > ECMAScript6(selected) and it didn't work.

我试过: 工具>选项>打字稿>项目>常规> ECMAScript6(已选择)但它没有用。

Also:

还:

npm install -g typescript

and it didn't work as well.

它也不起作用。

How do I tell VS to use Typescript 1.5.3 (which node.d.tdis asking for)?

我如何告诉 VS 使用 Typescript 1.5.3(这node.d.td是要求的)?

采纳答案by brando

I found out how to fix this. First, if you are using Resharper, as others have mentioned, you need to indicate the version of typescript you are using:

我发现了如何解决这个问题。首先,如果您使用的是 Resharper,正如其他人所提到的,您需要指明您使用的打字稿版本:

enter image description here

在此处输入图片说明

However, within Visual Studio you need to go to Tools/Extensions and Updatesand upgrade the Typescript extension to the latest version.
enter image description here

但是,在 Visual Studio 中,您需要转到工具/扩展和更新并将 Typescript 扩展升级到最新版本。
在此处输入图片说明

Do this by searching for "typescript" under the "installed" tab. In the yellow box I highlighted you should see a message saying that any available updates are available under the "Updates" tab. Go to the "Updates" tab and update your typescript extension to the latest version. (I had already made the update so no update selection is now available to me for Typescript).

通过在“已安装”选项卡下搜索“打字稿”来执行此操作。在我突出显示的黄色框中,您应该会看到一条消息,指出“更新”选项卡下有任何可用的更新。转到“更新”选项卡并将您的打字稿扩展更新到最新版本。(我已经进行了更新,因此现在我无法选择 Typescript 的更新选项)。

UPDATE:
It is simplest to go to download and install "Typescript for Visual Studio" to get the latest version: https://www.microsoft.com/en-us/download/details.aspx?id=48593

更新:
最简单的方法是下载并安装“Typescript for Visual Studio”以获取最新版本:https: //www.microsoft.com/en-us/download/details.aspx?id=48593

回答by adrian h.

It's a ReSharper setting. From the menu bar in Visual Studio, click ResharperOptionsCode EditingTypeScriptInspections, then change the TypeScript language levelto the relevant value.

这是一个 ReSharper 设置。从 Visual Studio 的菜单栏中,单击ResharperOptionsCode EditingTypeScriptInspections,然后将 更改TypeScript language level为相关值。

回答by JimiSweden

A little bit off topic but since I found this thread when looking for a solution on the error "ECMAScript 6 feature. Your current language level is: ECMAScript 5"...

有点离题,但因为我在寻找有关错误“ECMAScript 6 功能。您当前的语言级别是:ECMAScript 5”的解决方案时发现了这个线程...

I want to add a note on Antons comment about ES6 and Resharper 10.

我想在关于 ES6 和 Resharper 10 的 Anton 评论中添加一个注释。

If you get the error "ECMAScript 6 feature. Your current language level is: ECMAScript 5" it is possible to change the level in Resharper 9.1 as stated in this post How to use ECMAScript 6 syntax with Visual Studio 2013

如果您收到错误“ECMAScript 6 功能。您当前的语言级别是:ECMAScript 5”,则可以按照这篇文章如何在 Visual Studio 2013 中使用 ECMAScript 6 语法中所述更改 Resharper 9.1 中的级别

I′m running 9.2 now and just did this. Resharper Options > Javascript > Inspections > "change Javascript language level to ES6"

我现在正在运行 9.2,只是这样做了。Resharper 选项 > Javascript > 检查 > “将 Javascript 语言级别更改为 ES6”

回答by ProfK

There is now a TypeScript 1.5 for Visual Studio 2015. Get it at https://blogs.msdn.microsoft.com/typescript/2015/07/20/announcing-typescript-1-5/

现在有一个适用于 Visual Studio 2015 的 TypeScript 1.5。在https://blogs.msdn.microsoft.com/typescript/2015/07/20/annoucing-typescript-1-5/获取它

It's actually for VS 2013, but they imply strongly it will work with 2015 as well: "TypeScript 1.5 is part of the newly released Visual Studio 2015."

它实际上适用于 VS 2013,但他们强烈暗示它也适用于 2015:“TypeScript 1.5 是新发布的 Visual Studio 2015 的一部分。”

回答by Stephen Baker

Make sure you set the proper version in your project XML. See the node below:

确保在项目 XML 中设置了正确的版本。请参阅下面的节点:

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
  <TypeScriptTarget>ES6</TypeScriptTarget>
  <TypeScriptJSXEmit>None</TypeScriptJSXEmit>
  <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
  <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
  <TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
  <TypeScriptRemoveComments>False</TypeScriptRemoveComments>
  <TypeScriptOutFile />
  <TypeScriptOutDir />
  <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
  <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
  <TypeScriptSourceMap>True</TypeScriptSourceMap>
  <TypeScriptMapRoot />
  <TypeScriptSourceRoot>~/app/</TypeScriptSourceRoot>
  <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
</PropertyGroup>