yoavbls / pretty-ts-errors

🔵 Make TypeScript errors prettier and human-readable in VSCode 🎀
https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors
MIT License
13.29k stars 89 forks source link

Hide Unformatted TypeScript errors / move to after the pretty errors #3

Open robertmoura opened 1 year ago

robertmoura commented 1 year ago

Really loving the format of these errors! It's a lot easier to read.

The only thing I noticed is that the unformatted errors are still showing up. Was this intended or is there a way to remove them?

Screenshot 2023-04-13 at 9 04 08 am

Update / TLDR

This is currently intentional but there are plans to improve the experience. This could potentially be improved by:

The issue is that the improvements rely on changes to VS Code. Go upvote this issue if you want these changes!

@yoavbls wrote:

This is the issue that will eventually allow us to modify the order of the errors + mute the original error: https://github.com/microsoft/vscode/issues/54272

Samathingamajig commented 1 year ago

this is intended. https://github.com/yoavbls/pretty-ts-errors/blob/d055b017030f3c24a2c70fc74cc785d3fa49ada5/README.md?plain=1#L38

VSCode markdown blocks all styling options, so I had to find hacks to style the error messages. e.g., there isn't an inlined code block on VSCode markdown, so I used a code block inside a codicon icon, which is the only thing that can be inlined. That's why it can't be copied. but it isn't a problem because you can still hover on the error and copy things from the original error pane.

seahindeniz commented 1 year ago

Hmm. Well, if it's possible, having an option to disable them is much preferred than having a bunch of similar errors in a scrollable small container. For the copy-pasting issue, I believe the error translation feature and also the built-in Problems panel should be enough, since it shows the raw version of the error.

robertmoura commented 1 year ago

I agree! Would be great to have an option to disable them. Personally I never copy these errors anyway.

Samathingamajig commented 1 year ago

at most, i copy the error number, in this case ts(6196) or just 6196 and type ts in the search bar

yoavbls commented 1 year ago

@robertmoura Thank you for opening this issue 💁🏼‍♀️ As @Samathingamajig said, it is intended, but I planned to add an option to choose whether you want to see TypeScript original errors after I'll succeed in making the types copyable. Unfortunately, I failed to find a hack due to the strict limitations there: https://github.com/microsoft/vscode/blob/b0d7acec38cfab4d82630cba64d581bf1cd1a305/src/vs/base/browser/markdownRenderer.ts#L372

So, I'll explore adding a setting that will hide TypeScript's original errors very soon. Until then, if someone want to open a PR for that, you're more than welcome 🙂

Samathingamajig commented 1 year ago

Are extensions able to silence the errors of another extension?

tjx666 commented 1 year ago

@mjbvz @johnsoncodehk

yoavbls commented 1 year ago

@Samathingamajig Actually I didn't find any API of VSCode that allows that. Does someone have an idea how we can remove the original TypeScript diagnostics?

Maybe we should address it with a language service plugin like this guy did here? @johnsoncodehk @Samathingamajig @tjx666 WDYT?

Samathingamajig commented 1 year ago

Maybe we should address it with a language service plugin like this guy did here? @Samathingamajig WDYT?

Personally, I don't think it's worth it to try to silence the original error. Since formatting restricts the ability to copy/paste the error with the customize one, you get the benefit of being able to easily copy the raw error without going to the error panel. I would imagine silencing the error with a language service plugin would also remove the error from the error panel, as well as hiding it from your extension (unless your extension relies on a separate language server, which I doubt).

nicooprat commented 1 year ago

At least it would be cool to have the pretty error first in the tooltip 🤞

yoavbls commented 1 year ago

It was the first on the tooltip a while ago, I'm not sure why it changed. @johnsoncodehk has some breakthroughs there by moving the error-providing mechanism to the language service plugin. It'll allow us to control the order and hide the original errors.

We'll update about it soon 🙏🏼

johnsoncodehk commented 1 year ago

Just to clarify...don't expect it, the language server can cut the original error message, but this will also cause extensions like ErrorLens that rely on diagnostic messages to not work, so I don't think that's the way forward. Still need see VSCode how to improve.

In addition, the language server can only control the order of hover messages, but cannot make the hover messages displayed on top of the diagnosis.

Sorry for the false hopes.

corysimmons commented 1 year ago

Can someone just link to a VSCode repo Issue where we can 👍 some "Let us tweak this" issue?

estubmo commented 1 year ago

Maybe we should address it with a language service plugin like this guy did here? @Samathingamajig WDYT?

Personally, I don't think it's worth it to try to silence the original error. Since formatting restricts the ability to copy/paste the error with the customize one, you get the benefit of being able to easily copy the raw error without going to the error panel. I would imagine silencing the error with a language service plugin would also remove the error from the error panel, as well as hiding it from your extension (unless your extension relies on a separate language server, which I doubt).

A good solution for that would be to hide the original error, but add a button for copying it all to the clipboard.

Samathingamajig commented 1 year ago

A good solution for that would be to hide the original error, but add a button for copying it all to the clipboard.

read the last sentence

Samathingamajig commented 1 year ago

@RoyiNamir It could be made more prominent, however, it is mentioned on the main screen of the extension.

https://github.com/yoavbls/pretty-ts-errors/blob/d055b017030f3c24a2c70fc74cc785d3fa49ada5/README.md?plain=1#L38

VSCode markdown blocks all styling options, so I had to find hacks to style the error messages. e.g., there isn't an inlined code block on VSCode markdown, so I used a code block inside a codicon icon, which is the only thing that can be inlined. That's why it can't be copied. but it isn't a problem because you can still hover on the error and copy things from the original error pane.

(emphasis mine)

daaanny90 commented 1 year ago

@RoyiNamir A bit rude but I was expecting also only the beautified error. That's why I found this issue.

yoavbls commented 1 year ago

This is the issue that will eventually allow us to modify the order of the errors + mute the original error: https://github.com/microsoft/vscode/issues/54272

Every vote or comment could help!

@robertmoura Can you add it to the content of the issue please? 🙏🏼

blasco commented 1 year ago

This would be great, voting 👍

scottybrown commented 9 months ago

If this is expected behaviour, perhaps the README.md could be updated to better explain how it works.

Screenshot 2023-11-12 at 3 40 06 pm

This extension doesn't give you "this" "instead of that". It gives you both, and the ugly "that" gets priority. The only way to find out it's meant to work that way is to browse the issues :)

oscklm commented 9 months ago

I can confirm that the original "ugly" typescript errors in fact do appear over the "pretty" ones for me as well, feels like they were on top before, so might be as of lately that pretty ones appear below, sadly. For long error messages, this quickly makes the extension near useless, as scrolling the tiny little problems window is far from easy.

I would agree that the README should be updated to more accurately show how the errors will be displayed.

Hope that VSCode will allow for a way to work around this. It's sad, since the extension is def one of my favourites 🙏🏽

yoavbls commented 1 month ago

Until things will be changed, you can use this hack here: https://github.com/yoavbls/pretty-ts-errors/blob/main/docs/hide-original-errors.md