Datatables.net在TS 2.3.4上使用isDataTables抛出TS2339错误

时间:2017-06-09 19:08:45

标签: angular typescript datatables

使用datatables.net运行Angular 2,Typescript 2.3.4,Node 6.10.3:

├── @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

toggleTable代码开始抛出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;
}

node_modules/@types/jquery.datatables/index.d.ts的相关部分是:

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;

如何修复DataTable上的类型?

0 个答案:

没有答案