How to disable/suppress errors from libraries in T

2020-07-08 06:32发布

问题:

I have turned on some compiler switches to report more issues in code (e.g. strict null checks). But I get tens of errors in used libraries, e.g.:

[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>'.

Is there any way of suppressing/muting/disabling error checking in libraries (e.g. directory node_modules)?


It can't be a duplicate of Allow implicit any only for definition files because my question is much broader. I am not asking how to disable one specific check (noImplicitAny) in libraries, but how to disable all checks in libraries. However the answer from that question applies to mine as well - "skipLibCheck": true disables all checks in libraries.

回答1:

While this question is not a duplicate of Allow implicit any only for definition files the answer https://stackoverflow.com/a/39917362/1017211 from over there does solve my issue.

Edit tsconfig.json:

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