microsoft / microsoft/TypeScript

[tsserverlibrary] Allow reporting helpful links and error-names

Open
#39,009 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Search Terms

Support Links
Helpful Links
Diagnostic

Suggestion

VSCode now accepts either strings or numbers alongside with a support-link as the code-property of a Diagnostic, which provides the comfort to easily open up a website showing more details about the error:

https://github.com/microsoft/vscode-languageserver-node/blob/9466bf38aef41849b3d48a882e399a34e3127eb2/types/src/main.ts#L581-L624

It would be very awesome if TypeScript language services had the same option to not only pass a number as error-code but also strings and, most importantly, a link containing helpful info.

Use Cases

Basically whenever you use a plugin which reports errors especially when they're a tiny bit too complex to describe them in a few sentences.

Examples

        interceptor.AddMethod(
            "getSemanticDiagnostics",
            (target, delegate, fileName) =>
            {
                let diagnostics = delegate(fileName);
                diagnostics.push(
                    {
                        file: this.Program.getSourceFile(fileName),
                        start: 1,
                        length: 1,
                        messageText: "The member-ordering is incorrect.",
                        category: ts.DiagnosticCategory.Warning,
                        source: "eslint",
                        code: {
                            value: "import/order",
                            target: "https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md"
                        }
                    }
                return diagnostics;
            });

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.

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 tsserverlibrary diagnostic and language-service API types, then compare their Diagnostic code shape with the linked vscode-languageserver-node definition. Done means preserving numeric diagnostic codes while allowing the proposed string and helpful-link forms for plugin-reported diagnostics; the payload names no tests or implementation files.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.