microsoft / microsoft/TypeScript

Function parameter hover info is inconsistent between contexts

Aperta
#59,219 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

“hover”

🕗 Version & Regression Information
  • This changed between versions 5.4 and 5.5
⏯ Playground Link

https://www.typescriptlang.org/play/#code/PTAEFUGcFMCdQCbQGYEsB20Gg5VTQBZAEQA1Q0AbaSAOlAHVpEB7dQTAIAXUAYzc9gtKoTgAtUdAFCcAngAdmABUFzIoALygA3pNB7QkFgFtoylnIBcBgRgDmkgL6TJIUAEl0nOOgCGw0dCUCvCyCrTS8swkpADC-NCeZqoaoElqAGTafEZybAmckAD8VloOTpLIAK7oPJyobERkcZ75ABRyKpAlsNA+CGyUMqAA2gDSOOigANbQMizIjbHxiZ0AulbRzV4r5pBjqw4AlNq6+q76F5egAHqFp3quACoBIpFq86AduzhqHdCcslAAHcApNRCwAG5wOygSFwT6dRzOTbLTguMC3dGgZ7MULMD5fZISUCVWyDYGg0DgqGwGFw+AolqeLExHyTIHMIw+GYicS-HoAoY+NQcyiUQqpHrIOA+ABG5KBqDELEq3AwAhYCEqPBh6rgJgQqB8XipgWCrwUUiAA

💻 Code
// User defined inside MDX files. We don’t control this.
type Props = {
    someProp: string
}

// Internal helper type.
type MDXContentProps = Props & {components?: {}}

function MDXContent(props: {readonly [K in keyof MDXContentProps]: MDXContentProps[K]}) {
    //              ^?
    // The types of props is pretty when hovering over props
}

MDXContent
// ^?
// The type of props is ugly when hovering over MDXContent
// Can we make this pretty as well? Preferably without introducing intermediate helper types.

🙁 Actual behavior

Hovering over MDXContent shows the type of the props as written.

Hover info for MDXContent with TypeScript 5.5

🙂 Expected behavior

Hovering over MDXContent shows a pretty formatted type of the props, just like TypeScript 5.4.

Hover info for MDXContent with TypeScript 5.4

Additional information about the issue

I initially asked for help on Twitter to prettify this, not realizing this was a regression in TypeScript 5.5.

Later in the thread I was asked to report this bug.

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

Riproduci la differenza dell'hover usando il TypeScript Playground collegato e l'esempio MDXContent fornito, confrontando l'hover della dichiarazione di funzione con l'hover del riferimento alla funzione. Traccia il percorso di visualizzazione dell'hover per i tipi mappati e readonly; il lavoro è completato quando passando il mouse su MDXContent viene mostrato lo stesso tipo di props formattato di TypeScript 5.4.

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
Specificata chiaramente
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.