Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 + TypeScript 1.6.3 + JQuery

I'm using Visual Studio 2015, and I have a project that uses Typescript 1.6.3 and JQuery. The problem is that the

JQuery.data(key: string): any;

function should return any, but if I have a JQuery variable named "element" and I write:

element.data('field')

the Intellisense keeps saying the function returns JQuery instead of any. Also, it says the currently used overload is

JQuery.data(obj: { [key: string]: any; }): JQuery;

and not the one that accepts a simple string.

Am I missing something or is it known bug?

like image 953
Sergio Avatar asked Dec 02 '25 09:12

Sergio


1 Answers

You need to get an up-to-date version of jquery.d.ts from DefinitelyTyped. There was a change in the TypeScript compiler (https://github.com/Microsoft/TypeScript/issues/4619) that exposed an incorrect definition in the .d.ts file.

like image 74
Ryan Cavanaugh Avatar answered Dec 04 '25 22: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!