Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the jquery.d.ts TypeScript definition file throw a compile error?

Tags:

typescript

I have a basic MVC4 web project in VSTS 2012 to play around with TypeScript.

I installed this version of TypeScript: TypeScriptSetup.0.8.1.msi

I have the jquery.d.ts file from: http://typescript.codeplex.com/SourceControl/changeset/view/fe3bc0bfce1f#typings%2fjquery.d.ts

I am getting compile errors on all "index signature" definitions. The first compile error is with the JQueryAjaxSettings:

 headers?: { [key: any]: any; };

Here is the error:

Error 9 Index signatures may only take 'string' or 'number' as their parameter
C:\Development\TypeScript\ScriptGen\ScriptGen.Web\Scripts\jquery.d.ts 37 18 app.ts

The compiler doesn't like the key defined as type any.

Should I change the key type to string or is there something else I am missing?

like image 855
jedatu Avatar asked Nov 30 '25 20:11

jedatu


1 Answers

You're using an old version of jquery.d.ts. The compiler has changed since then to disallow any indexers. Any newer version of jquery.d.ts (e.g. this one) will work fine, or you can just change that any to string if you like (there have been multiple other fixes in that file in the interim you might want, though).

like image 153
Ryan Cavanaugh Avatar answered Dec 02 '25 10:12

Ryan Cavanaugh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!