tsdjs / tsd

Check TypeScript type definitions
MIT License
2.36k stars 68 forks source link

expectError doesn't work with // @ts-nocheck and others #192

Open y-polonsk opened 1 year ago

y-polonsk commented 1 year ago

For my test files, since a lot of testing is for ts errors, I don't want the errors to be flagged red in VSCode (since they are expected), so i used // @ts-nocheck. However, after this, all expectError(...) checks fail with "Expected an error, but found none". I also tried with // @ts-expect-error and // @ts-ignore, same problem.

Or is there any other way to tell VSCode not to flag expected errors and still have expectError(...) working correctly?

tommy-mitchell commented 1 year ago

I don’t think there’s a way to do it currently. tsd relies on the TypeScript compiler to find errors, and using @ts-expect-error suppresses the error from being reported at all.

I think this would be a good feature to add to a possible editor integration or an eslint plugin. For now, if the error squigglies are too bothersome for you, you could isolate all of your expectError assertions to their own file.

y-polonsk commented 1 year ago

Ok, i see. I wish the behavior of expectError in this regard was the same as for expectType: VSCode marks it as error only if expectType fails. So for expectError it should really mark it red only if expectError itself fails, that is, when the passed expression actually does not have an error.

tommy-mitchell commented 11 months ago

I think this would be a good feature to add to a possible editor integration or an eslint plugin.

See #196 for discussion on this.