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

Allow skipping diagnostics in .js file using comments and quick fixes to add them #14568

Merged
merged 9 commits into from
Mar 14, 2017

Conversation

mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Mar 10, 2017

Skip semantic errors in a .js file iff // @ts-suppress precedes them.
Also add two quick fixes:

  1. disable all checking in a file
  2. disable specific error by adding // @ts-suppress on the line before it




// @ts-suppress: no call signature

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.

Copy link
Contributor Author

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();

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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"
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

@mhegazy mhegazy merged commit 1fbbead into checkJSFiles Mar 14, 2017
@mhegazy mhegazy deleted the checkJSFiles_QuickFixes branch March 14, 2017 06:04
@mhegazy
Copy link
Contributor Author

mhegazy commented Mar 14, 2017

Merged into #14496

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants