错误: 打印脚本功能1.5。当前语言级别为1.4

我正在 VisualStudio2015的上下文中工作(使用 Resharper) ,并且正在引用 NodeJS 的 TypeScript 定义文件。我有3个其他 VS 项目,使用 node.d.ts没有问题。然而,在这个新项目中,我现在有146个错误说的是同样的事情:

“类型脚本功能1.5. 当前语言级别为1.4”。

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

我试过了: 工具 > 选项 > 打字稿 > 专题 > 常规 > ECMAScript6(选中) ,但是没有用。

另外:

npm install -g typescript

但效果并不好。

我如何告诉 VS 使用类型1.5.3(哪个 node.d.td要求) ?

23281 次浏览

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

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"...

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

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

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

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:

enter image description here

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

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).

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

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

<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>

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/

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 2019, click Extensions->search for Typescript 3.8 for VS, click to install, restart VS, the the VS/ReSharper will recognize the feature of Typescript 3.8. in project file Latest using "Latest" is a smart way.