108

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.ts without problems. In this new project, however, I now have 146 errors saying the same thing:

"Typescript Feature 1.5. Current language level is 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.

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

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.td is asking for)?

Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
brando
  • 8,215
  • 8
  • 40
  • 59
  • 1
    Does [this answer](http://stackoverflow.com/a/23294611/398606) help? – Sunil D. Aug 28 '15 at 18:52
  • Thx for the link. Looked promising but was not able to fix. I have two VS projects open. One references node.d.ts no problem, the other rejects it. Very strange. – brando Aug 28 '15 at 19:26
  • Not sure, but may be is related to bug in VS 2015 http://stackoverflow.com/questions/32273429/cannot-compile-modules-unless-the-module-flag-is-provided/32274106#32274106? – Artiom Aug 30 '15 at 14:30
  • You may be right Artiom. As far as I can tell, you can't actually use ECMAScript 6 in Visual Studio 2015 Community. Maybe in VS Code, but not the VS Community. The moment you reference, for example, "Import" it is flagged as not targeting the correct language level. So....how do you target the correct language level? – brando Aug 30 '15 at 22:21

6 Answers6

209

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.

Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
adrian h.
  • 2,996
  • 3
  • 18
  • 24
53

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

brando
  • 8,215
  • 8
  • 40
  • 59
9

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"

Community
  • 1
  • 1
JimiSweden
  • 744
  • 10
  • 13
  • Not off topic at all - very helpful. It's important to note that both the `JS` and `TS` inspections need to _both_ be set to their desired values. I was missing the `JS` inspection setting. – atconway Mar 01 '16 at 05:46
  • Please see [my comment](http://stackoverflow.com/a/36558296/412393) on an additional version setting for the "ECMAScript 6 feature. Your current language level is: ECMAScript 5" error. – sbaker Apr 11 '16 at 20:10
  • I was getting the error "**ECMAScript 2015 feature. Your current code level is: ECMAScript 5.**" This was the correct solution for me. (Noted here to hopefully help others Google their way to the answer more quickly!) – Brian Lacy Oct 12 '18 at 19:56
1

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

ProfK
  • 49,207
  • 121
  • 399
  • 775
0

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.

Alison Niu
  • 64
  • 3
-1

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>
sbaker
  • 89
  • 1
  • 7