22

Ever since I updated to the latest jQuery.d.ts definition file, using the Visual Studio NuGet package manager, I now get 100s of errors within the jQuery.d.ts file.

The pattern to all the errors is vertical lines like this:

index(selector: string|JQuery|Element): number;

which I assume indicates optional types. The errors mostly look like:

\Scripts\typings\jquery\jquery.d.ts(2797,34): error TS1005: Build: ',' expected.

The default Build Action was TypeScriptCompile, but changing that to none has no effect.

I am running Visual studio 2013 Professional release 4, so assumed I would have the latest TypeScript version, but this looks like a versioning issue.

Any ideas on how to resolve the problem.

iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202

3 Answers3

22

When you have an existing VS 2013 project that used an earlier version of TypeScript and you want to upgrade to the latest nuGet packages of jquery.d.ts or knockout.d.ts, installation of the latest TypeScript compiler is not enough.

After installing the latest TypeScript from
https://visualstudiogallery.msdn.microsoft.com/2d42d8dc-e085-45eb-a30b-3f7d50d55304
you need to edit project definition files to turn on version 1.4 features. This is done by changing the line
<TypeScriptToolsVersion>1.0</TypeScriptToolsVersion>
to
<TypeScriptToolsVersion>1.4</TypeScriptToolsVersion>

Also, please be aware that your TS code may require some changes too. Specifically, FormData constructor does not take HTML element as an argument anymore. The simplest workaround is to change code like this one:
var formData = new FormData(<HTMLFormElement>$("#form")[0]);
to
var formEl = <HTMLFormElement>$("#form")[0]; var formData = new window['FormData'](formEl);

Andrzej Turski
  • 626
  • 4
  • 5
  • https://stackoverflow.com/questions/23245395/use-specific-typescript-compiler-version-in-visual-studio/28704234#28704234 – pixelbyaj Feb 22 '16 at 10:10
14

TypeScript was updated (Jan 2015) after Visual Studio 2013 release 4 (Nov 2014):

You can get the latest TypeScript compiler here: https://visualstudiogallery.msdn.microsoft.com/2d42d8dc-e085-45eb-a30b-3f7d50d55304

Additionally you may have to update the TypeScriptToolsVersion setting in any old csproj files:

They may currently look like this:

<TypeScriptToolsVersion>1.0</TypeScriptToolsVersion>

change to 1.4 for VS 2013 release 5:

<TypeScriptToolsVersion>1.4</TypeScriptToolsVersion>
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
  • You may also have to update the path environment variable by removing the path for TypeScript 1.0 ... For the command line tool to work. – Choco Jun 11 '15 at 23:36
0

I got the same error after upgrading from Visual Studio 2013 to Visual Studio 2015.

I used the change of <TypeScriptToolsVersion>1.0</TypeScriptToolsVersion> to <TypeScriptToolsVersion>1.4</TypeScriptToolsVersion> as suggested in other answers and it seemed to work, although Visual Studio 2015 had a warning suggesting I remove the line altogether.

So for Visual Studio 2015, removing the following line from the affected .csproj file seems to work better:

<TypeScriptToolsVersion>1.0</TypeScriptToolsVersion>
SharpC
  • 6,974
  • 4
  • 45
  • 40