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

Improve structure, formatting, (human) parsability and readabiliy of errors #29059

Open
5 tasks
emattias opened this issue Dec 17, 2018 · 3 comments
Open
5 tasks
Labels
Committed The team has roadmapped this issue Domain: Error Messages The issue relates to error messaging Suggestion An idea for TypeScript

Comments

@emattias
Copy link

emattias commented Dec 17, 2018

Suggestion

Comparing my DX/UX experience from working with flow versus TypeScript, the error messages is one of the few things that I preferred how flow does it. Especially after flow v0.66 release. I believe they integrated alot from the glow project. I would love it if typescript would adopt some for the formatting and helpful information that flow has in their error messages.

This blog post explains more about the flow 0.66 error message changes: http://medium.com/flow-type/better-flow-error-messages-for-the-javascript-ecosystem-73b6da948ae2

Here are a couple of things I can think of that would help me find the actual problem/conflict that I can take action on:

  • prettifying/formatting the outputted types
  • syntax highlighting
  • bold/highlight the conflicting parts

Use Cases

Every time typescript finds an error (which us developers will have to read and understand and take action on :) ). I am talking both on the command line but also in IDEs like vscode. There is an issue related to this in the vscode repo here: microsoft/vscode#54503

Examples

Heres and example of the ginormous unstructured blob of text that is a ts error with big types involved:

Type '({ expandedRowIds, orderBy, currentPage, filters: { columns: columnFilters, period, categoryIds }, ...restUrlQueryState }: Pick<Overwrite<DataGridUrlQueryStateUrlSerialized, { filters: { columns: { promotionName?: string | undefined; startDate?: string | undefined; endDate?: string | undefined; "sumFacts.switching.amount"?: string | undefined; "sumFacts.netLift.profit"?: string | undefined; "sumFacts.netLift.amount"?: string | undefined; }; period: Date[]; categoryIds: string[]; }; }>, "hiddenColumnNames" | "filters" | "orderBy" | "expandedRowIds" | "currentPage">, pageSize: any) => Dictionary<any>' is not assignable to type '(a: Overwrite<DataGridUrlQueryStateUrlSerialized, { filters: { columns: { promotionName?: string | undefined; startDate?: string | undefined; endDate?: string | undefined; "sumFacts.switching.amount"?: string | undefined; "sumFacts.netLift.profit"?: string | undefined; "sumFacts.netLift.amount"?: string | undefined; }; period: Date[]; categoryIds: string[]; }; }>) => DataGridQueryVariables'.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior 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, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@weswigham
Copy link
Member

We spoke with the vscode team and got microsoft/vscode#64566 opened a few days ago. We're already looking at it 😉

@weswigham weswigham added Suggestion An idea for TypeScript Committed The team has roadmapped this issue Domain: Error Messages The issue relates to error messaging labels Dec 17, 2018
@sjelfull
Copy link

Improving this and doing something like what Flow is doing would save so many people so much pain. As far as I can tell not much have happened in VS Code on that front. There is also the output in CLI to think about.

This could be hidden behind a toggle if backwards compatibility is a worry.

@emattias
Copy link
Author

emattias commented May 9, 2022

now 4 years later @mattpocock made this vscode extension that is a nice improvement along the lines I was thinking: https://github.com/mattpocock/ts-error-translator :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Domain: Error Messages The issue relates to error messaging Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants