Visual studio 如何将JQuery.Datatable扩展与Typescript一起使用?:不可分配给类型为'的参数;设置';
我看到了问题,但在我的项目中找不到旧的JQuery.Datatable类型文件的证据,所以我不知道问题来自何处。我使用的不是Nuget,而是npm。我不知道是否有其他方法可以引用该类型,或者Visual studio 如何将JQuery.Datatable扩展与Typescript一起使用?:不可分配给类型为'的参数;设置';,visual-studio,typescript,datatables,typescript-typings,Visual Studio,Typescript,Datatables,Typescript Typings,我看到了问题,但在我的项目中找不到旧的JQuery.Datatable类型文件的证据,所以我不知道问题来自何处。我使用的不是Nuget,而是npm。我不知道是否有其他方法可以引用该类型,或者.DataTable({responsive:true})调用的参数是否有不同的语法 Error TS2345 (TS) Argument of type '{ responsive: boolean; }' is not assignable to parameter of type 'Setting
.DataTable({responsive:true})
调用的参数是否有不同的语法
Error TS2345 (TS) Argument of type '{ responsive: boolean; }' is not assignable to parameter of type 'Settings'.
Object literal may only specify known properties, and 'responsive' does not exist in type 'Settings'.
package.json:
"devDependencies": {
"@types/datatables.net": "^1.10.8",
"@types/jquery": "^3.2.16",
"@types/knockout": "^3.4.46",
"@types/knockout.mapping": "^2.0.30",
"@types/knockout.validation": "0.0.35",
"@types/requirejs": "^2.1.31",
"@types/underscore": "^1.8.5",
"css-loader": "^0.28.7",
"datatables-bootstrap3-plugin": "0.5.0",
"datatables-epresponsive": "0.0.3",
"datatables.net": "^1.10.16",
"datatables.net-dt": "^1.10.16",
fooViewModel.ts
import * as ko from "knockout"
import * as $ from "jquery"
import "datatables.net";
import "datatables-epresponsive";
import "datatables.net-dt";
export class FooViewModel {
constructor() {
super();
this.instantiateLocalObjects();
if (this.containerIsLoaded()) {
this.onPageIsActive();
$("#employeeTable").DataTable({ responsive: true } );
}
}
更新:似乎问题是特定于尝试使用
数据表扩展(例如响应和选择)。例如
这不会抛出错误:
问题是实际上每个扩展都有类型文件,我安装了
datatables-epresponsive
认为它是datatables-responsive
我必须跑:
npm install --save datatables.responsive.typings
npm install datatables.net-responsive
我还尝试使用select,并需要:
npm install --save @types/datatables.net-select
问题是实际上每个扩展都有类型文件,我安装了
datatables-epresponsive
认为它是datatables-responsive
我必须跑:
npm install --save datatables.responsive.typings
npm install datatables.net-responsive
我还尝试使用select,并需要:
npm install --save @types/datatables.net-select
部分工作,仍然获取警报
行不是一种方法…
但解决了约90%的问题部分工作,仍然获取警报行不是一种方法…
但解决了约90%的问题