microsoft / microsoft/TypeScript

Show error when JSDoc tags use unknown Symbols

Open
#42,093 0 comments 1 reaction 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

Suggestion

Raise error when JSDoc tags reference unknown types

🔍 Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

is:issue is:open in:title jsdoc error
is:issue is:open in:title jsdoc validate

✅ 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 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, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Just like unknown symbols are compilation errors, raise also errors when using unknown symbols within JSDoc comments

📃 Motivating Example

      class TestWebsite {}

      /** @link {TestWebsite-Bogus} */
      /** @see {TestWebsite-Bogus} */
      /** @type {TestWebsite-Bous} */

There is no error on those references

💻 Use Cases

Typescript already takes type hints from JSDoc comments. Why not close the loop and also type-check JSDoc??

My most frequent code documentation case is referencing symbols and files within comments. However since these are never validated it is normal that with time and some refactorings those references become invalid.

It would be of a great help getting compilation errors on comment references. After all wrong/bad code documentation is worst than no documentation. JSDoc deserves static validation too!

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 by reviewing the suggestion and its JSDoc examples, then locate the existing JSDoc type-checking and diagnostic tests; the issue names no files or test entry points. Done means unknown symbols referenced by JSDoc tags such as @link, @see, and @type produce compilation errors without changing emitted JavaScript.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.