使用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
上的类型?