Skip to content

@ts-nocheck and @ts-ignore should also disable suggestions #47315

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

Open
5 tasks done
gomain opened this issue Jan 5, 2022 · 4 comments
Open
5 tasks done

@ts-nocheck and @ts-ignore should also disable suggestions #47315

gomain opened this issue Jan 5, 2022 · 4 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@gomain
Copy link

gomain commented Jan 5, 2022

Suggestion

🔍 Search Terms

@ts-ignore tsserver disable

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

The // @ts-nocheck and // @ts-ignore directive should, also, disable tsserver providing suggestions

📃 Motivating Example

When writing code ,it's nice that we get real time compile & linting errors & warnings (i.e. suggestion). TSSERVER, the language server for typescript, dose the heavy-lifting for your favorite IDE and fills your screen with all those wiggly lines you hate (& love).

Sometime, though, the language server can get it wrong. You are using a feature that's too new. You depend on a library unknown to the server. Or that you are writing buggy code intentionally. To our rescue, we can use directives to tell typescript (and its language server) that "it's ok, I know, roll with it". Directives such as

// @ts-nocheck: ignore this file
// @ts-ignore: ignore next line

are very handy.

Unfortunately, these directives didn't work with suggestions. Things like

'foo' is declared but its value is never read. [6133]
File is a CommonJS module; it may be converted to an ES module. [80001]

Still populated your IDE, and you jump through them like hoops trying to reach the error you want to fix. They are not ignored by placing the directives.

Released with typescript X.X, these directives can now be used to switch off suggestions as well.

💻 Use Cases

ts-ignore
This is a capture from Emacs' lsp-mode. For conventional reasons, we still want to continue using the commonjs style require and module.exports in js projects.

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Jan 6, 2022
@RyanCavanaugh
Copy link
Member

Still populated your IDE, and you jump through them like hoops trying to reach the error you want to fix.

Not to render the original suggestion moot, but this seems like a bug in the editor. VS Code, for example, will not navigate to a Suggestion diagnostic when you invoke the "Go to next error" command.

@gomain
Copy link
Author

gomain commented Jan 6, 2022

this seems like a bug in the editor. VS Code, for example, will not navigate to a Suggestion diagnostic when you invoke the "Go to next error" command.

Yes, in Emacs (Flycheck) we can set a minimum error level too. But that is opting out of all suggestions. Some suggestions are useful and (by choice) treated as errors - goto & fix.

We should be able to selectively switch off suggestions, like we can do with errors.

Even better, a way to switch of specific suggestions for the entire project (i.e. via tsconfig) either by code or by class. But with directives is a good start.

@kshetline
Copy link

I'm adding my voice as one more person who wants @ts-ignore to work with suggestions just as it does with errors.

@mortie
Copy link

mortie commented May 4, 2025

Hi, this is actually pretty important. Suggestions are useless if I can't either fix them or suppress them, and there are situations where fixing them is impossible. With no ability to suppress individual suggestions, the next best alternative is to disable suggestions altogether, which isn't great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants