microsoft / microsoft/TypeScript

Richer Diagnostic Display Meta-Issue

Open
#41,860 10 comments 31 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Domain: Error Messages Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

This issue tracks a couple of different useful ideas for making diagnostics "richer" for display purposes. We've wanted some of these for a while, and they're partially inspired by testing tools like Jest and Mocha. We've also seen tools like Rust, Rome, and Flow prove them out to some extent.

Long-term, you could imagine them being interactive with the a richer compiler client.

Printing Messages Across Lines

Types can get unwieldy, and displaying them inline makes it harder to see where things begin/end.

Type

    { x: string, y: number }

is not assignable to

    { x: string, y: string }

Notice no punctuation at the end. Not sure if we can generalize messages that way.

Also not sure how this plays well with

  • tools that parse our output.
  • diagnostic elaborations

Highlighted Spans in Messages

Imagine being able to highlight individual sections inside of types to indicate where the issue occurs.

                              vvvvvvvvvvv
Type '{ a: string; b: number; c: boolean; }' is not assignable to type '{ a: string; b: number; }'.
                              ^^^^^^^^^^^
  Object literal may only specify known properties, and 'c' does not exist in type '{ a: string; b: number; }'.

Diff Highlighting in Messages

Basically imagine red being the provided color, with green being an expected color.

Type '[string, number, boolean]' is not assignable to type '[string, string, boolean]'.
               ^^^^^^                                                ^^^^^^
               rrrrrr                                                gggggg

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. First review the three proposed areas—multi-line messages, highlighted spans, and diff highlighting—along with their compatibility concerns, then identify the relevant diagnostic display code and tests before proposing a scoped implementation. Done requires an agreed design and validation for the selected diagnostic behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.