Suppressing certain errors e.g. TS7017 in tsconfig.json

13,127

Solution 1

Suppressing certain errors

There is no option for that at the moment. I've created an issue to track it : https://github.com/Microsoft/TypeScript/issues/11051

Solution 2

As of TypeScript 2.6 (released on Oct 31, 2017), there is a way to ignore all errors from a specific line using // @ts-ignore comments before the target line.

The mendtioned documentation is succinct enough, but to recap:

// @ts-ignore
const s : string = false

disables error reporting for this line.

As for specifying certain errors, the current state is discussed here, in Design Meeting Notes (2/16/2018) and further comments, which is basically

"no conclusion yet"

and strong opposition to introducing this fine tuning.

Solution 3

This specific error message is a noImplicitAny error message. that means you have passed --noImplicitAny to the compiler. if you so desire to shut it off, then do not set the flag.

One thing to note is that the TypeScript compilers errors do not impact your output. the output is generated regardless. so if you wish to ignore all errors, you can.

The errors for things that are tangential to the type system work are all managed by flags, e.g. noImplicitAny, noImplictThis, noUnusedLocals, noUnusedPrameters, noImplicitReturs, etc..

Other errors are a signal from the compiler that something went wrong during checking your code. silencing the error does no guarantee that the type system has i\correctly understood your code. this does not guarantee that your program is consistent, or, and this is more important, that you will not get explainable errors in other parts of the system.

I would be intrested to know what specific errors you find superflous, and would like to suppress

Share:
13,127

Related videos on Youtube

Lonely
Author by

Lonely

Love doesn't make the world go round. Love is what makes the ride worthwhile. F.P. Jones

Updated on September 16, 2022

Comments

  • Lonely
    Lonely over 1 year

    Is it possible, if yes, how? I want to achieve something like (e.g., in the compilerOptions in tsconfig.json):

    // ATTENTION PSEUDO CODE
    suppressErrors: ['TS7017', ....]
    

    p.s. TS7017: Index signature of object type implicitly has an 'any' type.

    EDIT: FYI, I would like to suppress any desired error; TS7017 is only an example.

  • Lonely
    Lonely over 7 years
    Thank you but I would like to suppress any desired error, TS7017 is only an example.
  • Fabian Lauer
    Fabian Lauer over 7 years
    @Lonely The title of your question says 'Suppressing certain errors' — which errors do you want to suppress? The only other error suppression option I know of is --suppressExcessPropertyErrors, maybe that can help. BTW, typescriptlang.org/docs/handbook/compiler-options.html
  • Lonely
    Lonely over 7 years
    everything related to this like this[whatever] which is syntactically and semantically correct, outputs TS7017 Error. I can suppress that with (this as any)[whatever], that is my current solution and it was (I think) your idea at Microsoft's Platform.
  • Ka Tech
    Ka Tech over 2 years
    Thank you, i have been looking everywhere for this. Other comments like // tslint:disable-next-line did not work