microsoft / microsoft/TypeScript

Duplicated jsdoc should error

Open
#24,996 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

checkJs Domain: JavaScript In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

It's possible to document parameters and function expressions 2-3 different places in JSDoc. However, I can't think of a good reason to do so, and I suspect that it's (1) rare (2) by mistake. Here's an example:

/** @param a - the a */
function f(/* an a */ a) {
}

Today gives the jsdoc

 an a
 - the a

But should give an a and an error on @param a: "Duplicate jsdoc".

The problem is even worse in JS, where jsdoc provides types. Here, the innermost type annotation provides the type and the rest are ignored. This should definitely be an error:

/** @param {string} a */
function f(/* @type {number} */ a) {
}

This example should have an error on @param a: "Duplicate jsdoc"

Thanks to @bterlson for this idea.

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 tracing how TypeScript parses and merges JSDoc on parameters and function expressions, using the two examples in the issue as repro cases. Done means duplicate parameter documentation and conflicting inline type annotations produce a "Duplicate jsdoc" error while preserving the specified diagnostic behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.