We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
QuickInfo Generics
Most of the time types which include generics are very hard to understand.
It would be great if there would be a expand feature for QuickInfo (e.g. a + button inside the tooltip) which tries to evaluate generics.
+
If that it not possible it would be great if an CompilerAPI would be available to allow IDE plugin developers to create a type explorer.
const example1 /** 1 **/ = flatten({ firstLetter: 'A', secondLetter: { value: 'B' } }) const example1 /** 2 **/: { firstLetter: { id: string }, secondLetter: { id: string } } = example1;
type FancyGeneric<TBase> = TBase extends string ? { id: string } : TBase extends { value: string } ? { id: string } : TBase; type FancyGenericMap< TInputStructure extends { [key in keyof TInputStructure]: string | { value: string } } > = { [key in keyof TInputStructure]: FancyGeneric<TInputStructure[key]> }; function flatten<TInput extends { [key in keyof TInput]: string | { value: string } }>(input: TInput): FancyGenericMap<TInput> { const result: FancyGenericMap<TInput> = {} as FancyGenericMap<TInput>; (Object.keys(input) as Array<keyof typeof input>).forEach((key) => { const value: string | { value: string } = input[key]; result[key] = { id: typeof value === 'string' ? value : value.value } as FancyGeneric<TInput[keyof TInput]>; }); return result; } const example1 = flatten({ firstLetter: 'A', secondLetter: { value: 'B' } }) const example2: { firstLetter: { id: string }, secondLetter: { id: string } } = example1;
Playground
As you can see the types are the same for /** 1 **/ and /** 2 **/ but lets compare the QuickInfo:
/** 1 **/
/** 2 **/
The first QuickInfo for /** 1 **/
const example1: FancyGenericMap<{ firstLetter: string; secondLetter: { value: string; }; }>
In this case you can not tell the structure of the object without reading the FancyGenericMap implementation.
FancyGenericMap
Lets see in contrast the second QuickInfo for /** 2 **/:
const example2: { firstLetter: { id: string; }; secondLetter: { id: string; }; }
For the second example it is way easier to understand the structure.
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered:
Duplicate of #25784 and #28508
Sorry, something went wrong.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Search Terms
QuickInfo
Generics
Suggestion
Most of the time types which include generics are very hard to understand.
It would be great if there would be a expand feature for QuickInfo (e.g. a
+
button inside the tooltip) which tries to evaluate generics.If that it not possible it would be great if an CompilerAPI would be available to allow IDE plugin developers to create a type explorer.
Examples
Relevant part of the example (click to enlarge):
Full ExamplePlayground
As you can see the types are the same for
/** 1 **/
and/** 2 **/
but lets compare the QuickInfo:The first QuickInfo for
/** 1 **/
In this case you can not tell the structure of the object without reading the
FancyGenericMap
implementation.Lets see in contrast the second QuickInfo for
/** 2 **/
:For the second example it is way easier to understand the structure.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: