【问题标题】:error TS2339: Property 'name' does not exist on type 'KnockoutExtenders'错误 TS2339:“KnockoutExtenders”类型上不存在属性“名称”
【发布时间】:2020-07-06 19:52:24
【问题描述】:

我尝试在 TypeScript 中使用敲除,我认为我遇到了与 here 相同的问题,但我找不到需要安装的类型。代码行是:

ko.extenders.name = function (target : string) {

错误是:

error TS2339: Property 'name' does not exist on type 'KnockoutExtenders'.

我该如何解决这个问题?

我的代码中的其他相同类型的错误是:

error TS2339: Property 'number' does not exist on type 'KnockoutExtenders'.

error TS2339: Property 'modal' does not exist on type 'JQuery<HTMLElement>'.

代码

$('#signup-dialog').modal('show');

【问题讨论】:

  • 看起来像是 knockoutjs KnockoutExtenders 类型没有 name,也没有 number 属性 @types/knockoutjs。对于.modal,您肯定需要导入特定的plugin

标签: typescript typescript-typings knockout-3.0


【解决方案1】:

看起来.modal() 来自 Bootstrap。所以我不得不通过npm install --save-dev @types/bootstrap 安装引导类型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    • 2019-09-13
    • 2019-01-21
    • 2016-08-13
    • 2017-12-20
    • 2016-11-14
    相关资源
    最近更新 更多