You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API consumers such as typescript-eslint would benefit from being able to get the diagnostics in a file that would be emitted were it not for a // @ts-expect-error or // @ts-ignore. Can we add in an options parameter to program.getPreEmitDiagnostics to allow consumers to stop those comment directives from suppressing errors?
We try to keep our API surface pretty minimal. Since it's an API call, you can transform the source text (replace ts-ignore with ts-zzzzzz) before handing it over to get equivalent results. Thoughts?
No juice π. We need to be able to get the original text in case of anything that transforms text. For example, ESLint rule complaints can have fixers that move entire functions / other chunks of code. Fixers have no way of knowing that the user has configured @typescript-eslint/parser -> @typescript-eslint/estree with some setting like { rewriteDirectives: true }.
Rewriting the comments also has the concerns about duplicated parsing work mentioned in the OP (unless it's just a dumb text-based find/replace but that feels problematic).
Suggestion
π Search Terms
ignore comment directives ts-expect-error ts-ignore
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
API consumers such as typescript-eslint would benefit from being able to get the diagnostics in a file that would be emitted were it not for a
// @ts-expect-error
or// @ts-ignore
. Can we add in an options parameter toprogram.getPreEmitDiagnostics
to allow consumers to stop those comment directives from suppressing errors?I threw together a rough draft of how this could look in the TypeScript source here: JoshuaKGoldberg/TypeScript@a7c07ff...JoshuaKGoldberg:TypeScript:get-diagnostics-options. Just in case it's helpful.
π Motivating Example
JoshuaKGoldberg/eslint-plugin-expect-type#65: we'd like to make lint rules that assert on the error message matching what's expected, as a userland solution to #19139 not being accepted.
π» Use Cases
Here's how we could change what
eslint-plugin-expect-type
does today:Without this API, users either:
The text was updated successfully, but these errors were encountered: