Skip to content

Duplicate JSDoc in union of derived interfaces #43213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sandersn opened this issue Mar 12, 2021 · 2 comments · Fixed by #43240
Closed

Duplicate JSDoc in union of derived interfaces #43213

sandersn opened this issue Mar 12, 2021 · 2 comments · Fixed by #43240
Labels
Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Milestone

Comments

@sandersn
Copy link
Member

interface I {
    /** The colour */
    readonly colour: string
}
interface A extends I {
    readonly colour: "red" | "green";
}
interface B extends I {
    readonly colour: "yellow" | "green";
}
type F = A | B
const f: F = { colour: "green" }
f.colour/**/

Expected behavior:

Quickinfo at /**/

(property) I.colour: string

The colour

Actual behavior:

(property) I.colour: string

The colour
The colour

From my notes on discord explaining to the person who noticed this:

The function in the TS services is called getDocumentationComment, and it does three things:

  1. calls another function to get the comment text to display
  2. loops over each declaration after uniquifying
  3. per-declaration, gets the comment text from the base, if there is any

For the example above, colour has two declarations, since it's a union: Apple.colour and Banana.colour. So:

Step 1. No comment text from either declaration.
Step 2. There are two unique declarations to iterate over.
Step 3. Each declaration has the same base, which contributes the same comment.

#35170 has separate jsdocs for each, as you point out.
#32708 only has one extended declaration, just instantiated with two generic types

@sandersn sandersn added Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Mar 12, 2021
@sandersn sandersn added this to the Backlog milestone Mar 12, 2021
@hahmadia
Copy link
Contributor

I'd like to take a look at this.

@hahmadia
Copy link
Contributor

Submitted a fix in #43240

hahmadia added a commit to hahmadia/TypeScript that referenced this issue Mar 19, 2021
sandersn pushed a commit that referenced this issue Mar 19, 2021
* Concat on unique values

* more changes

* only push values to array if unique

* address review comments

* Fix lint

* removw foeachunique
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants