Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function parameter hover info is inconsistent between contexts #59219

Open
remcohaszing opened this issue Jul 10, 2024 · 1 comment
Open

Function parameter hover info is inconsistent between contexts #59219

remcohaszing opened this issue Jul 10, 2024 · 1 comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@remcohaszing
Copy link

🔎 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.

@jakebailey
Copy link
Member

Bisects to #58078, though reverting it does not seem to actually change this behavior back.

Note that we more or less always want to be writing declarations back as they were written, as that's an invariant to make isolatedDeclarations work. Hover uses the same logic, but at some level this is related to #59029 and whether or not we need a hover mode which tries to do this "prettification".

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants