-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow skipping diagnostics in .js file using comments and quick fixes to add them #14568
Conversation
|
||
|
||
|
||
// @ts-suppress: no call signature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it supposed to work in .ts
files too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope. js only and only for semantic errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -90,6 +90,7 @@ | |||
"codefixes/fixes.ts", | |||
"codefixes/helpers.ts", | |||
"codefixes/importFixes.ts", | |||
"codefixes/unusedIdentifierFixes.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to add an entry in src/harness/tsconfig.json
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
Merged into #14496 |
Skip semantic errors in a .js file iff
// @ts-suppress
precedes them.Also add two quick fixes:
// @ts-suppress
on the line before it