microsoft / microsoft/TypeScript

Add structure to diagnostics to enable nicer diagnostic output and interactivity in tooling such as IDEs

Open
#57,180 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔍 Search Terms

diagnostics, interactive errors, structured diagnostics, error formatting

✅ Viability Checklist
⭐ Suggestion

change diagnostics to some structured data instead of plain strings. At its simplest this would be including an array of the sources for the text that populates the substitution variables in the diagnostic message strings. If we also keep a cache or recent sources and include a key into that cache in the diagnostic, then we can provide callback functionality for tools to get more information in both the TS api and tssserver.

📃 Motivating Example

IDEs can provide much richer displays for error messages and even add interactivity. Imagine having syntax highlighting for types or being able to click to "go to definition" in an error message.

A very rough proof of concept showing an enhancement to the problems view in VsCode

https://github.com/microsoft/TypeScript/assets/84949734/25f8366d-a94e-44fb-bfd2-9f204be96097

💻 Use Cases
  1. What do you want to use this for?
    a. Better display and interaction with error message
  2. What shortcomings exist with current approaches?
    a. Currently only possible by parsing error text.
    b. Advanced usages require traversing the AST to find the nodes and types that contribute to the error
  3. What workarounds are you using in the meantime?
    a. see 2.

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

Start with the diagnostics exposed through the TypeScript API and tssserver, then compare the current plain-string diagnostics with the suggested structured data and source information. Review how IDE tooling currently parses messages or traverses the AST; done means tools can obtain richer diagnostic context and support interactive displays without changing existing runtime behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, tooling
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.