Definitelytyped: Jquery typing causing issue in 2.0.44

Created on 16 May 2017  路  5Comments  路  Source: DefinitelyTyped/DefinitelyTyped

Hi,

I updated to Jquery typing 2.0.44 from 2.042, this caused my project generating lots of compilation errors during "npm start". After spending a few hours I realized this was caused by missing one line of code in 2.0.44 from 2.0.42.

In file node_modules\@types\jqueryindex.d.ts line 3333, "[index: string]: any;" was removed in the new version, and causing my jquery validation to fail loading in Angular 4 application.

Putting back this line in the index.d.ts file, everything works just fine.

Please advise why is this is causing issue and why was this line removed?

Thanks

John

ERROR in feature-base-component.ts (103,25): Property 'valid' does not exist on type 'JQuery'.

ERROR in feature-base-component.ts (253,22): Property 'fdatepicker' does not exist on type 'JQuery'.

ERROR in feature-base-component.ts (289,30): Property 'mask' does not exist on type 'JQuery'.

ERROR in feature-base-component.ts (304,21): Property 'tooltipster' does not exist on type 'JQuery'.

ERROR in Dsonal-info.component.ts (105,15): Property 'mask' does not exist on type 'JQuery'.

  • [ yes] I tried using the @types/xxxx package and had problems.
  • [yes ] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [ ] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [ ] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @....

All 5 comments

This was changed by #16398.
You can fix the errors by adding declarations for whatever methods you are injecting, as in:

interface JQuery {
    valid(x: SomeType): boolean;
}

This declaration should appear in global scope, so it could be ambiently in a .d.ts file or in a declare global {} block.

Hi Andy,

Thanks for the explanation, I typed these jquery functions in the my project's typing.d.ts file and the errors have gone away.

Much appreciated!

John

@andy-ms I am also seeing this issue. If i stay with @types/jquery v2.0.43 works fine but if i upgrade to >= 44 or latest 2.0.48, causing typing issue like this. For now, I am downgrading to the working version of 2.0.43 The solution mentioned above isn't best idea for me because i have 1000 of functions like bootstraps an other. Is there any better solution? Thanks.

Typescript
2.4.1

If these custom functions are coming from a library, you could see if we already have type definitions for them. For example, @types/bootstrap contains a lot of jquery extensions.

@andy-ms Thanks, I will consider for new project.

Was this page helpful?
0 / 5 - 0 ratings