microsoft / microsoft/TypeScript

Intersection type intellisense duplicates jsdoc, rather than overriding

Offen
#30,901 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Experience Enhancement Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

  • 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"
}
Pasted_Image_4_12_19__4_05_PM

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"
}
Pasted_Image_4_12_19__4_05_PM

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))

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Es wird keine Quelldatei und kein Test genannt. Beginne damit, die bereitgestellten Intersection-Type- und Interface-Beispiele in TypeScript IntelliSense zu reproduzieren, und verfolge anschließend die Verarbeitung von JSDoc für geschnittene Eigenschaften durch den language-service; fertig ist die Aufgabe, wenn die Dokumentation des nächstgelegenen Typs ohne duplizierte geerbte Kommentare angezeigt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers, developer-experience
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.