Mute/ignore TS2307 error from TypeScript tsc

前端 未结 3 628
悲&欢浪女
悲&欢浪女 2021-02-12 05:26

Is there a way to mute the TS2307 error from the TypeScript tsc compiler?

It makes it really hard to spot real/new errors and warnings as there are many

3条回答
  •  既然无缘
    2021-02-12 06:18

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

    The mentioned documentation is succinct enough, but to recap:

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

    disables error reporting for this line.

    However, this should only be used as a last resort when fixing the error or using hacks like (x as any) is much more trouble than losing all type checking for a line.

    As for specifying certain errors, the current (mid-2018) 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.

提交回复
热议问题