Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ts-expect-error only for a certain type of error

Tags:

typescript

Is it possible to make //ts-expect-error directive only cover a concrete error and not others?

Example of code I would like to silent but only for some kind of error:

enter image description here

Error TS2588 enter image description here

Error TS2339 enter image description here

I would expect something like ESLint does with rules: //@ts-expect-error TS2339 to only silent errors of that kind, for example.

like image 838
OscarDOM Avatar asked Sep 11 '25 04:09

OscarDOM


1 Answers

It's not currently possible - this has been a long standing request; one of the underlying issues is that the error codes are moving targets, as they're not meant to be used for explicit referencing.

like image 149
Gareth Jones Avatar answered Sep 13 '25 21:09

Gareth Jones