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

Using @ts-expect-error in a @ts-nocheck file #39427

Closed
nicojs opened this issue Jul 5, 2020 · 5 comments
Closed

Using @ts-expect-error in a @ts-nocheck file #39427

nicojs opened this issue Jul 5, 2020 · 5 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@nicojs
Copy link

nicojs commented Jul 5, 2020

TypeScript Version: 3.9 - 4.0.0-beta, v4.0.0-dev.20200705

Search Terms: "ts-nocheck ts-expect-error" "ts-expect-error"

Code

// @ts-nocheck
// @ts-expect-error
'a' - 'b'

Expected behavior: No compile error

Actual behavior: Error: Unused '@ts-expect-error' directive.(2578)

Playground Link: https://www.typescriptlang.org/play?ts=4.0.0-beta#code/PTAEAEBcGcFoDsD2BjAFgU2QawFAgjLOgB4AOmkRATlYlTgOQCGDosoDARg0A

Related Issues:

@RyanCavanaugh
Copy link
Member

image

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Mar 8, 2021

What direction does this bug point @RyanCavanaugh? I would think that the code is behaving as expected: the // @ts-expect-error is redundant and shouldn't exist. Perhaps a more specific error message?

Error: Unused '@ts-expect-error' directive because of an earlier '@ts-no-check' directive.
  '@ts-no-check' was specified here: ...

Per the comments in stryker-mutator/stryker-js#2403 (comment) I think the right resolution would be for fancy code mutation services to strip out comments. cc @nicojs, since it looks like you already implemented that in stryker-mutator/stryker-js#2365, right?

edit: my comment double-posted; I deleted the second one...

@RyanCavanaugh
Copy link
Member

I think nocheck is the higher-order bit here; the intent of that is to "shut up for the whole file" and that should include expect-error not issuing an error.

@JoshuaKGoldberg
Copy link
Contributor

This actually doesn't give an error anymore in 4.1.5 and up: original example; example with code between the two comments. 🤷

@RyanCavanaugh
Copy link
Member

Must have been fixed elsewhere then.

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

No branches or pull requests

3 participants