Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

100+ errors in jQuery.d.ts since getting latest via nuget in MVC application

Tags:

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.

like image 549
Gone Coding Avatar asked Feb 17 '15 10:02

Gone Coding


2 Answers

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

like image 137
Andrzej Turski Avatar answered Oct 07 '22 05:10

Andrzej Turski


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> 
like image 24
Gone Coding Avatar answered Oct 07 '22 03:10

Gone Coding