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

Ability to group errors together #15550

Closed
tmkn opened this issue May 3, 2017 · 4 comments
Closed

Ability to group errors together #15550

tmkn opened this issue May 3, 2017 · 4 comments
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@tmkn
Copy link

tmkn commented May 3, 2017

TypeScript Version: 2.3.1

Use Case
I'm currently checking a huge(60+ files) js code base with the new // @ts-check option added in 2.3.1.
It works great and I started with 1 file, gradually adding more and more files to check, however in every file there are DOM manipulations and TypeScript rightfully complains about them, however after a while the log is FULL of TS2339 errors and it's incredibly hard to find other errors that I'm more interested in like missing variables or wrong assignments.

It would be really helpful if the compiler could group errors together to conserve space, so errors like TS2339 would only occupy 1 line per file instead of 1 line per occurrence.

Unless there's a // @ts-check way of telling the compiler that it is indeed a HTMLInputElement. I tried it with JSDoc syntax but to no avail.

I understand this is only helpful for people who use the // @ts-check option since you can always cast in a TS environment, but since you can now check pure JS it would be really helpful to group errors together for the use case described above.

So instead of this:

javascript/util/Util.js(134,69): error TS2339: Property 'value' does not exist on type 'HTMLElement'.
javascript/util/Util.js(137,61): error TS2339: Property 'value' does not exist on type 'HTMLElement'.
javascript/util/Util.js(139,61): error TS2339: Property 'value' does not exist on type 'HTMLElement'.
javascript/util/Util.js(147,57): error TS2339: Property 'value' does not exist on type 'HTMLElement'.

The output should be more like this, 1 line per file:

javascript/util/Util.js(134,69), (137,61), (139,61), (147,57): error TS2339.

I know this isn't ideal because it would also affect non DOM queries as TS2339 is not exclusive to it, but I get A LOT and I looked through all of them, eliminated all the other TS2339 occurences so now only the DOM queries remain and I would like them to occupy less space in my log output.

Idk if it makes sense to specify it in the tsconfig.json or jsconfig.jsonfile, as it's more of an adhoc behaviour where if you see that your log is getting cluttered with a specific error you would then like to group those error messages to preserve space.
e.g tsc -groupErrors TS2339
Maybe even a // @ts-check style comment to group it on a per file basis?

@RyanCavanaugh
Copy link
Member

How would this feel?

javascript/util/Util.js(134,69): error TS2339: Property 'value' does not exist on type 'HTMLElement'.
   4 other occurrences in this file: lines 137, 139, 147, 165

@RyanCavanaugh RyanCavanaugh added Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript labels May 3, 2017
@mhegazy
Copy link
Contributor

mhegazy commented May 3, 2017

would that be something that your IDE supports? like VS has sort by Error code as well as source file. VS Code does not seem to have that..

@tmkn
Copy link
Author

tmkn commented May 4, 2017

@RyanCavanaugh Yes, that would also be an option, I like the indentation, if you skim over the log output you can quickly identify grouped errors and move on.

Sou you want to group errors by exact error message? Meaning several TS2339 errors in Util.js would result in this:

javascript/util/Util.js(134,69): error TS2339: Property 'value' does not exist on type 'HTMLElement'.
   4 other occurrences in this file: lines 137, 139, 147, 165
javascript/util/Util.js(234,69): error TS2339: Property 'checked' does not exist on type 'HTMLElement'.
   2 other occurrences in this file: lines 17, 39
javascript/util/Util.js(136,8): error TS2339: Property 'statistics' does not exist on type '{}'.
javascript/util/Util.js(145,8): error TS2339: Property 'Service' does not exist on type '{}'.

I think that approach would work pretty well.

--
Ideally there would be a new error type for DOM queries and if you use // @ts-check it would dismiss them as there's currently no way to fix those errors in a pure JS environment.

@RyanCavanaugh
Copy link
Member

This doesn't seem to come up often to to warrant what would ultimately be a pretty complex solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants