-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this
Milestone
Description
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:
- calls another function to get the comment text to display
- loops over each declaration after uniquifying
- 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
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this