microsoft / microsoft/TypeScript

Inline tsdoc comment support

Aperta
#39,290 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando gli esempi di tipi TypeScript proposti e il caso d’uso dichiarato di TSDoc e IDE-autocomplete. Determina quale comportamento del parser, della gestione dei commenti e dell’editor è interessato, quindi definisci test che dimostrino che i commenti inline sono associati ai campi corretti senza modificare l’output a runtime.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers, developer-experience
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.