Allow skipping diagnostics in .js file using comments and quick fixes to add them#14568
Allow skipping diagnostics in .js file using comments and quick fixes to add them#14568mhegazy merged 9 commits intocheckJSFilesfrom
Conversation
|
|
||
|
|
||
|
|
||
| // @ts-suppress: no call signature |
There was a problem hiding this comment.
This is just an arbitrary message rather than something indicating a specific diagnostic to suppress, right?
Could be useful to have a way to give a specific one to hide (say, something matching @ts-suppress\(T(\d+)\)), in a similar way how linter comments have a way to give a specific rule to disable; but that could be a future enhancement.
There was a problem hiding this comment.
That is what i had in mind with test. but the error code seemed fairly useless. like you need to go somewhere to know what TS 20124 means. Linter rules usually have descriptive names.
I think this is something we can target for in the future.
|
|
||
|
|
||
| /// @ts-suppress | ||
| x(); |
There was a problem hiding this comment.
Is it supposed to work in .ts files too?
There was a problem hiding this comment.
nope. js only and only for semantic errors.
There was a problem hiding this comment.
I actually wanted this functionality in .ts a few days ago -- embedding a chunk of stable JS code in TS code.
Sometimes you need to embed code rather than have it as an external module, for encapsulation. Such as, I was writing a plugin that needed to use compression, and I've embedded LZW algo in my ts plugin.
Of course LZW algo in JS needed a bunch of : any kicks to pass TSC checks. Would be great to be able to exclude chunks of code in TS from checks in such cases.
| "codefixes/fixes.ts", | ||
| "codefixes/helpers.ts", | ||
| "codefixes/importFixes.ts", | ||
| "codefixes/unusedIdentifierFixes.ts" |
There was a problem hiding this comment.
Do you need to add an entry in src/harness/tsconfig.json as well?
|
Merged into #14496 |
Skip semantic errors in a .js file iff
// @ts-suppressprecedes them.Also add two quick fixes:
// @ts-suppresson the line before it