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

Colour coded error messages #50019

Open
5 tasks done
Visual-Dawg opened this issue Jul 23, 2022 · 3 comments
Open
5 tasks done

Colour coded error messages #50019

Visual-Dawg opened this issue Jul 23, 2022 · 3 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@Visual-Dawg
Copy link

Visual-Dawg commented Jul 23, 2022

Suggestion

Typescript error messages can be a bit verbose sometimes. Color coding them and formatting them better (in reference to #45896) would greatly improve their readabillity.

🔍 Search Terms

Colour code, color code, syntax highlighting, formatter, error messages

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behaviour of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

A plus:
Colour coded visual difference for type errors, for example when unions do not match or a required property is missing.

📃 Motivating Example

Images speak a thousand lines of code (I messed up the formatting a bit. I did this by hand in an online tool..)
big output
difference

💻 Use Cases

Overall useful as current error messages are hard to read, especially with big complex types.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Jul 28, 2022
@orta
Copy link
Contributor

orta commented Sep 12, 2022

A small types highlighter is something I've been thinking about for the twoslash hovers in the site ( shikijs/twoslash#159 ) which could perhaps feed two birds with one feeder.

@Visual-Dawg
Copy link
Author

Any updates on this? Especially when working with a lot of generics or simply complex types, the error messages are very hard to read and this change would help a lot

@Visual-Dawg
Copy link
Author

This VS Code plugin came to rescue:
https://github.com/yoavbls/pretty-ts-errors?tab=readme-ov-file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants