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

Support TS 3.9 @ts-expect-error comment? #388

Closed
karlhorky opened this issue Jun 25, 2020 · 4 comments · Fixed by #389
Closed

Support TS 3.9 @ts-expect-error comment? #388

karlhorky opened this issue Jun 25, 2020 · 4 comments · Fixed by #389

Comments

@karlhorky
Copy link
Contributor

Hi @ikatyang,

First of all, thanks for the awesome project, really useful!

I was wondering what your feelings are on supporting the // @ts-expect-error comments from TypeScript 3.9.

Right now, my test files have errors in them (in the editor), because the lines after // @dts-jest:fail:snap should actually have an error:

Screen Shot 2020-06-25 at 18 05 28

What I would like to be able to do would be to use // @ts-expect-error either in the place of:

// @ts-expect-error
mergeArrays([]);

...or in addition to the dts-jest annotations:

// @dts-jest:fail:snap
// @ts-expect-error
mergeArrays([]);

or...

// @ts-expect-error
// @dts-jest:fail:snap
mergeArrays([]);

or even...

// @ts-expect-error @dts-jest:fail:snap
mergeArrays([]);

...none of which currently work.

Not sure if this is a feasible ask actually, but it would be nice to clean up more errors in my project!

@karlhorky
Copy link
Contributor Author

Wow, super fast @ikatyang, thanks! I'll upgrade now!

@karlhorky
Copy link
Contributor Author

karlhorky commented Jun 27, 2020

Ah, just trying this out, I guess this doesn't allow using snapshots. I guess that means I need to remove my snapshots when upgrading to this.

I suppose this is not super critical, but it would be nice to be able to configure that as well, in case it should test against the snapshot:

// @ts-expect-error @dts-jest:fail:snap

Regarding compatibility, the rest of the line after @ts-ignore or @ts-expect-error is recommended to be used to describe why the error is being suppressed, which seems to fit this use case:

It is recommended practice to have the remainder of the comment following @ts-ignore explain which error is being suppressed.

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-6.html#suppress-errors-in-ts-files-using--ts-ignore-comments


In case you're open to this, but it would be a feature for later, I can also open a new issue for this.

@ikatyang
Copy link
Owner

Ah, sorry. I did not explain what the new usage is. Basically, @ts-expect-error is treated as an alias of @dts-jest:fail, which means you could use // @ts-expect-error:snap [description] to replace // @dts-jest:fail:snap [description], and snapshots are still supported for sure.

Let me know if you have any question.

@karlhorky
Copy link
Contributor Author

karlhorky commented Jun 28, 2020

Ohh, didn't catch the [flags] in the readme there, sorry! Should have seen that.

Edit: I've opened a quick PR to add an example for that: #390

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

Successfully merging a pull request may close this issue.

2 participants