[Typescript v3.9] ts-expect-error

Typescript v3.9 introduces the @ts-expect-error assertion added to TypeScript 3.9. This assertion is more descriptive than @ts-ignore because, rather than just ignoring the next line, it is explicitly ignoring a compiler error.

// @ts-expect-error
const num: number = 'hello'
// @ts-ignore
const num2: number = 'hello

Both will work.

 

If change to:

ts-expect-error: means that this should have error, but I want to ingore it. if it compile correctly, then it report a error.

If this is not longer be an error, means that something has been changed.

 

It can help if the types is defined in another file, it was modified without benn notified

posted @ 2020-11-15 22:45  Zhentiw  阅读(1023)  评论(0编辑  收藏  举报