Datatables.net throwing TS2339 error with isDataTables on TS 2.3.4

Datatables.net throwing TS2339 error with isDataTables on TS 2.3.4

dmauldindmauldin Posts: 1Questions: 1Answers: 0

https://stackoverflow.com/questions/44465139/datatables-net-throwing-ts2339-error-with-isdatatables-on-ts-2-3-4

Running Angular 2, Typescript 2.3.4, Node 6.10.3, with datatables.net:

├── @types/jquery.datatables@1.10.36
├── datatables.net@2.1.1
├── datatables.net-buttons@1.3.1
├── datatables.net-buttons-zf@1.3.1
├── datatables.net-responsive@2.1.1
├── datatables.net-responsive-zf@2.1.1
├── datatables.net-zf@2.1.1

The toggleTable code started throwing TS2339:

error TS2339: Property 'isDataTable' does not exist on type '{ (param?: ResponsiveDataTablesSettings): DataTable; (param?: Settings): DataTable; }'.

toggleTable() {
    if (! $.fn.DataTable.isDataTable('#sample-table')) {
        this.setupSampleTable();
    }
    this.table = !this.table;
}

The relevant section of node_modules/@types/jquery.datatables/index.d.ts is:

interface JQuery {
    DataTable(param?: DataTables.Settings): DataTables.DataTable;
}

export interface StaticFunctions {
    /**
    * Check is a table node is a DataTable or not
    *
    * @param table Selector string for table
    */
    isDataTable(table: string): boolean;

How do I fix the type on DataTable?

Answers

  • allanallan Posts: 61,821Questions: 1Answers: 10,127 Site admin
    edited June 2017

    I suspect that the type definition file doesn't include the static functions. You'd need to contact the author of that file - it isn't actually published as part of the DataTables project.

    Having said that, I'm loving TypeScript myself and do plan to make some time to fold in a typing information in future - when I get a chance.

    Allan

This discussion has been closed.