microsoft / microsoft/TypeScript

Display default values for property types.

Aperta
#61,045 0 commenti 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
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms
  • jsdoc property and default tooltip
  • jsdoc declare default values on object properties
  • use jsdoc property with default
🕗 Version & Regression Information

Unsure if it's always been this way.

⏯ Playground Link

https://www.typescriptlang.org/play/?filetype=js#code/LAKFHoCpNACTYAEAuBPADgUwCaYGawDeA9gEYBWmAxsgL6wAKATsegM5wKLotZNpEA5GwC2g2AB9YgkdnFTBAGwDmg+gG1mrNgDo2ASwBemALwy5AXVgAhAK7JkxAHawDxnZyQ9WmfqiJsyEz6TsoaWuw6igCGpJiKVnYOzrAxcYoeIPDgoBDQnohMmMi2TE5sRBFstAW4eNG2ishErkaYAFzSsoIANKmx8Z22TnUhOLA1WZA5IHjDNPopysVVABQAlERwsDtFJWVEk5OgisUtbpiwJl1yfWnxE1ewy8hr66BAA

💻 Code
/**
 * @typedef {object} Props
 * @property {'sm' | 'md' | 'lg'} [Props.size='md'] Button size.
 * @property {string} [Props.label] Button label.
 */

/**
 * @returns {Props}
 * @default { size: 'md', label: undefined }
 */
function getProps() {
    return {}
}

let { size = 'md', label } = getProps()
🙁 Actual behavior

Tooltip when hovering size destructured property:

let size: "sm" | "md" | "lg"
Button size.
🙂 Expected behavior

Tooltip when hovering size destructured property:

let size: "sm" | "md" | "lg"
Button size.
---
@default 'md'
Additional information about the issue

Potentially relates to https://github.com/microsoft/TypeScript/issues/24746

When defining object property types using JSDoc default value notation, such as @property {'sm' | 'md' | 'lg'} [Props.size='md'], I'd like to see tooltip details about the default value. I assume the only way to denote default values with @property is to use [key=value] notation since @default cannot be inlined.

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 con il TypeScript Playground collegato e riproduci il caso del valore predefinito JSDoc @property, quindi confrontalo con l’issue correlata 24746. Traccia come viene prodotto il tooltip della size destrutturata e fai in modo che il comportamento completato mostri il valore predefinito documentato, ad esempio @default 'md'.

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

Valutazione

Stack tecnologico
javascript, typescript
Ambito
compilers, developer-experience
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.