microsoft / microsoft/TypeScript

Inline tsdoc comment support

Offen
#39,290 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Search Terms

tsdoc, comments, IDE, line sorting

Suggestion

When writing a type, sometimes you want to add more information to a field that will be surfaced in IDE autocomplete. Currently you must define them like this:

export type BoxSizeDefinition = {
  /** this is null for non-custom box sizes */
  itemCount: number | null
  size: BoxSize
  /** A description for the range of pounds included in box. */
  poundage: string
  /** price in cents of the box size */
  price: number
}

Note that the comment is above the field. This is problematic because auto-sorting linters and such will mangle the comments.

I propose also supporting inline tsdoc comments:

export type BoxSizeDefinition = {
  itemCount: number | null /** this is null for non-custom box sizes */
  size: BoxSize
  poundage: string /** A description for the range of pounds included in box. */
  price: number /** price in cents of the box size */
}

This effectively fixes the sorting problem.

Use Cases

Adding descriptive text to be shown via IDE autocomplete for fields (currently supported, but not in a sorting & codeaction-friendly way.)

Examples

See above

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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

Beginne mit der Überprüfung der vorgeschlagenen TypeScript-Typbeispiele und des beschriebenen TSDoc- und IDE-autocomplete-Anwendungsfalls. Ermittle, welches Parser-, Kommentarverarbeitungs- und Editorverhalten betroffen ist, und definiere anschließend Tests, die zeigen, dass Inline-Kommentare den richtigen Feldern zugeordnet werden, ohne die Laufzeitausgabe zu verändern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers, developer-experience
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

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