【问题标题】:How to disable/suppress errors from libraries in TypeScript?如何禁用/抑制 TypeScript 库中的错误?
【发布时间】:2017-03-08 20:00:24
【问题描述】:

我已打开一些编译器开关以报告代码中的更多问题(例如,严格的 null 检查)。但是我在使用的库中遇到了数十个错误,例如:

[default] xxx/node_modules/@angular/core/src/util/decorators.d.ts:11:5
    Property 'extends' of type 'Type<any> | undefined' is not assignable to string index type 'Function | any[] | Type<any>'.

是否有任何方法可以抑制/静音/禁用库中的错误检查(例如目录 node_modules)?


它不能与Allow implicit any only for definition files 重复,因为我的问题要广泛得多。我不是在问如何在库中禁用 一个 特定检查 (noImplicitAny),而是在问如何在库中禁用 all 检查。然而,该问题的答案也适用于我的 - "skipLibCheck": true 禁用库中的所有检查。

【问题讨论】:

标签: angular typescript compiler-errors


【解决方案1】:

虽然这个问题不是 Allow implicit any only for definition files 的重复问题,但那边的答案 https://stackoverflow.com/a/39917362/1017211 确实解决了我的问题。

编辑tsconfig.json:

{
    "compilerOptions": {
        "skipLibCheck": true,
        ...
    },
    ...
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-19
    • 2017-03-02
    • 1970-01-01
    • 2023-03-19
    • 2012-03-24
    • 2012-10-29
    • 2011-02-11
    相关资源
    最近更新 更多