Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript 1.4: Wrong syntax highlighting in Visual Studio

Typescript 1.4 has been released recently, providing new possibilities like unions.

I installed the new version for Visual Studio, however the syntax highlighting doesn't recognise unions:

var member: string|number;

Although it can be compiled without problems, the syntax checker hovers the definition and any usage of the variable member.

What do I need to update to get this working?

like image 711
maja Avatar asked Jan 17 '15 18:01

maja


3 Answers

Rather than turning off Resharper, you could configure it to ignore analysing errors in *.ts files. (Tools -> Options -> Resharper Options -> Code Inspection -> Settings -> File Masks to Skip -> add *.ts)

This way you still benefit from using Resharper for other files, and you also get the benefits of code formatting and the like for TypeScript using Resharper.

like image 116
Don Avatar answered Oct 22 '22 22:10

Don


I was having a similar issue where Resharper was not recognizing the "const" keyword.

I fixed this by explicitly telling Resharper what version of TypeScript to use. By default it is set to "auto detection".

On the menu, go to Resharper > Options > Code Editing > TypeScript.

Change the Type Script Language Level to "1.5 (experimental)"

like image 6
Steven Moseley Avatar answered Oct 23 '22 00:10

Steven Moseley


I've had the same issue, and for me it was Resharper that was causing the problem.

If you have Resharper installed then simply disable it while working on TypeScript 1.4, at least until JetBrains releases an update with 1.4 support.

To disable Resharper: Tools -> Resharper -> General -> Suspend

like image 3
Acidic Avatar answered Oct 22 '22 22:10

Acidic