pretty-ts-errors icon indicating copy to clipboard operation
pretty-ts-errors copied to clipboard

Hide Unformatted TypeScript errors / move to after the pretty errors

Open robertmoura opened this issue 1 year ago • 22 comments

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:

  • Removing the original error
  • Changing the order of the errors so that the pretty version is on top

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

robertmoura avatar Apr 12 '23 23:04 robertmoura

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.

Samathingamajig avatar Apr 13 '23 05:04 Samathingamajig

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.

seahindeniz avatar Apr 13 '23 06:04 seahindeniz

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

robertmoura avatar Apr 13 '23 06:04 robertmoura

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

Samathingamajig avatar Apr 13 '23 06:04 Samathingamajig

@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 🙂

yoavbls avatar Apr 13 '23 18:04 yoavbls

Are extensions able to silence the errors of another extension?

Samathingamajig avatar Apr 13 '23 18:04 Samathingamajig

@mjbvz @johnsoncodehk

tjx666 avatar Apr 14 '23 07:04 tjx666

@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?

yoavbls avatar Apr 15 '23 23:04 yoavbls

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).

Samathingamajig avatar Apr 15 '23 23:04 Samathingamajig

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

nicooprat avatar Apr 17 '23 12:04 nicooprat

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 🙏🏼

yoavbls avatar Apr 18 '23 09:04 yoavbls

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.

johnsoncodehk avatar Apr 18 '23 10:04 johnsoncodehk

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

corysimmons avatar Apr 18 '23 16:04 corysimmons

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.

estubmo avatar Apr 19 '23 02:04 estubmo

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 avatar Apr 19 '23 03:04 Samathingamajig

@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)

Samathingamajig avatar Apr 20 '23 06:04 Samathingamajig

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

daaanny90 avatar Apr 21 '23 10:04 daaanny90

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? 🙏🏼

yoavbls avatar Apr 21 '23 22:04 yoavbls

This would be great, voting 👍

blasco avatar Aug 28 '23 10:08 blasco

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 :)

scottybrown avatar Nov 12 '23 04:11 scottybrown

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 🙏🏽

oscklm avatar Nov 21 '23 09:11 oscklm

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

yoavbls avatar Jul 31 '24 21:07 yoavbls