microsoft / microsoft/TypeScript
Intersection type intellisense duplicates jsdoc, rather than overriding
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
- VSCode Version: 1.33.1
- OS Version: macOS 10.12.6
Does this issue occur when all extensions are disabled?: Yes
Sorry if the title isn't clear, it's tricky to put into words but obvious with code. The gist is when a type is extended and has the same key, the intellisense combines the documentation, rather than the "child" overriding it, like they do with interface. It's easier to explain with an example.
When intersecting types with the same property, the intellisense documentation shows all of the comments instead of just the latest:
type Duck {
/** This is a really great duck */
id: string
}
type Mallard = Duck & {
/** I love this duck */
id: string
}
const duckMan: Mallard = {
id // intellisense here shows "This is a really great duck I love this duck"
}
However, with an interface, the intellisense shows only the direct type comment, which is expected.
interface Duck {
/** This is a really great banana */
id: string
}
interface Mallard extends Duck {
/** I love this duck */
id: string
}
const duckMan: Mallard = {
id // Intellisense says "I love this duck"
}
I found this out because I'm using graphql-codegen to generate types for my GraphQL schema. It generates types, and the intellisense in some cases repeats many times.
Expectation
I would expect the "closest" comment doc of a type to override all of the others, like it does with an interface. If there's a reason that can't work, then at least having a uniqueness check would be good, maybe new Set(typedocs))
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non è indicato alcun file sorgente né alcun test. Inizia riproducendo gli esempi forniti di intersection type e interfacce in TypeScript IntelliSense, quindi segui la gestione di JSDoc per le proprietà intersecate nel language-service; il lavoro è terminato quando viene mostrata la documentazione del tipo più vicino senza commenti ereditati duplicati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers, developer-experience
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100