≡

DataTables 3.1.3: Type 'JQuery' is not generic

DataTables 3.1.3: Type 'JQuery' is not generic

SLorenzSLorenz Posts: 7Questions: 2Answers: 0

Error messages shown:

node_modules/datatables.net/types/types.d.ts(1252,93): error TS2315: Type 'JQuery' is not generic.

Description of problem:

When using DataTables 3.1.3 TypeScript reports that the type JQuery is not a generic type.
The error references the following line from datatables.net package in file types/types.d.ts:

type LayoutComponent = LayoutElement | LayoutFeatures | (() => HTMLElement) | HTMLElement | JQuery<HTMLElement> | Dom | null;

DataTables' own declaration of the interface JQuery is in fact not generic (also taken from types.d.ts):

declare global {
    //...
    interface JQuery {
        //...
    }
}

As a workaround I've installed @types/jquery. This fixes the issue using TypeScript 5.9.3. However, using TypeScript 6.0.3 the error is reported again.

Would you mind to either declare the type JQuery to be generic or use it only in a non-generic way?
Thank you!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 66,097Questions: 1Answers: 11,019 Site admin
    Answer ✓

    Very good point - thank you and sorry I missed that error.

    I've committed a change to address that error and it will be in the next patch release.

    Allan

  • SLorenzSLorenz Posts: 7Questions: 2Answers: 0

    Thank you, I appreciate that!

Sign In or Register to comment.