如何禁用/抑制TypeScript库中的错误?

mon*_*nef 3 compiler-errors typescript angular

我打开了一些编译器开关,以报告代码中的更多问题(例如,严格的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>'.
Run Code Online (Sandbox Code Playgroud)

有什么方法可以抑制/消除/禁用库(例如目录node_modules)中的错误检查?


它不能与“ 仅允许用于定义文件”隐式允许重复,因为我的问题要广泛得多。我不是在问如何禁用库中的一项特定检查(noImplicitAny),而是如何禁用库中的所有检查。但是,该问题的答案也适用于我的- "skipLibCheck": true禁用库中的所有检查。

mon*_*nef 7

尽管此问题不是“ 仅对定义文件允许隐式任何问题”的重复,但是从那儿来的答案/sf/answers/2794215371/确实解决了我的问题。

编辑tsconfig.json

{
    "compilerOptions": {
        "skipLibCheck": true,
        ...
    },
    ...
}
Run Code Online (Sandbox Code Playgroud)

  • 我已经设置了 `skipLibCheck: true` 但我在一个库中有 ts 错误。我直接从 github 安装的唯一库(其余的来自标准 npm 存储库)。知道为什么skipLibCheck在这里不起作用吗? (3认同)