Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The jquery.d.ts definition is generating many errors in TypeScript 0.9

I'm new to TypeScript, when include jquery.d.ts getting many syntax errors while building the code, I'm using VS express 2012. To include the jQuery definition I have use the following code:

/// <reference path="./jquery.d.ts" />

I get a lot of errors just from the definition file - such as this:

Error   109 Index signature parameter type must be 'string' or 'number'.    D:/Able/TypeScript/HelloWorld/HelloWorld/jquery.d.ts    54  20  HelloWorld

Here is the screen shot of error...

enter image description here

Why is the definition file generating errors?

like image 403
Able Alias Avatar asked Jul 03 '13 18:07

Able Alias


1 Answers

The TypeScript definition you have won't work in the TypeScript 0.9 compiler.

You can get the latest version from either...

Codeplex or Definitely Typed

You'll notice that the indexers are updated from:

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

To

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

This is to comply with tighter compiler rules that state the key must be a string or a number.

like image 180
Fenton Avatar answered Oct 14 '22 23:10

Fenton