microsoft / TypeScript Public
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
[CLI DX] Improve positioning of compiler error messaging info #45717
Comments
One question, one suggestion:
Edit: Adding bullets will help (1) a lot, I think, so I hope not much additional adaption will be needed. |
4.4
After
So I think the first related span should have a newline with a separation. Will trigger something with a deeper set of relations to look at next. |
Before
After
I'm not certain it's the most elegant answer, because I think the existing indentation is paying for itself in these reports. Separating with a newline does help in the readability a bunch though. The largest chains come from TS2322, which I have separate ideas to address outside of this issue. |
Another related example, these related have a source code location to display: Before
After
|
@orta can I give it a shot? |
Sure, give it a shot - until there's a solid WIP PR it's open for anyone to give it a go. |
thanks @orta ! Fair enough will start work on it, what would be a good starting point? |
I'd start at trying to just scope the output like this:
to
Then work on more complex bits once you're comfy |
Hello @mdaj06 ! Hope you are working on it, please let me know if there is any change in plan |
Hey @prabhatmishra33 i was side tracked with another set of tasks, will be picking up where i left off! |
One thing to note is that in the earlier error message, With the new layout, the error code and error message cannot be selected easily in case someone want's to google it. Simply searching the error code does reveal answers to common problems, but there could be cases where the message would be necessary. Apart from this, new one looks awesome! |
Note: This is still up for debate, but we think this is a pretty strong contender to ship. We may still change our minds on details. So, if you give it a shot, expect some of us to come in and maybe make changes at the end of the PR's lifecycle.
Suggestion
As of 4.4, a run of
tsc
looks like:I propose instead we make the output terminal length aware, and by using that information we change the whitespace and positioning of the different pieces of information.
Example
This change does not add any new lines to the output. There's a reasonable argument that we might want an extra new-line between the location and source code though, might have to get a feel for this in prod. We also switch from
~
to▔
to "fake" a full linebreak.Details
We take into account the knowledge about the width of the current terminal in order to provide more space between the key elements of the TS output.
● is a sigil per-compiler message, and lives on its own column. This means you can easily see when compiler messages start/end
The
TS1234
error message is de-empathized and moved to the right, these messages are useful for searching the internet for similar problems but are less valuable for understanding the errors. I dropped 'error' from that message because aside from #45714 we always show errors here.Code is moved above the error message. There's two ideas in play here:
Notes
We had a lot of design experiments ranging from rust-y, eslint-y, errata-y, miette-y but we've got quite a lot of backwards compatibility guarantees to keep and this proposal is about the wrapping to the error messaging - and it leaves individual error messages to be able to do a better job of giving context.
We want these to be safe to copy & paste (it should be better now the message is on its own lines) and parsable via regexes for things like problem matchers (though they now need to be multi-line to grab the message)
Exceptions
If we do not know the width of the terminal or it is too thin ( < 60 cols) then we drop all fancy re-ordering and leave it to your terminal to handle. This means:
The text was updated successfully, but these errors were encountered: