Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
y-polonsk opened this issue Apr 19, 2023 · 3 comments
Open

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

y-polonsk opened this issue Apr 19, 2023 · 3 comments

Comments

@y-polonsk
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants