-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Expansion of a generic type with Promise not working in VsCode (and in PlayGroung) 'type X<T> = () => T | Promise<T>;' #38760
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
Comments
I was working on a project and I realize that some type may have been simplified but the mater of my request is only regarding the |
TLDR version: Code: type MaybePromise<T> = T | Promise<T>
type AsReturnType<T> = () => MaybePromise<T> Expected: Hover over symbol Actual: Hover over symbol Playground: Reasoning: Most of the other cases (unions and whatnot; see original post) expanded and de-duped types for hover, so the "base" I'm personally not sure what's the "best" behaviour here, but first instinct says it should have somewhat consistent hover expansion behavior. |
HO my god tanks I will do an effort to never do something like this again (I feel so ridicule tanks @AviVahl)
|
I don't understand the wall of text and I don't understand the example. Where is |
@RyanCavanaugh I had typos when renaming stuff, which broke the example. Check out the current expected/actual (my previous comment). |
I am not as good as you to explain myself I still would like to be able to express my problem. Here is another version of the problem
I want to be able to work with something like |
I want to use a function export async function promisseOf<V>(value: V | Promise<V>): Promise<V> {
return Promise.resolve(value).then(async x => x);
} The const valueMap_P: <Promise<MaybeList<HMSETResult>>>(value: T_PT_<Promise<MaybeList<HMSETResult>>>) => ValueMap_P<Promise<MaybeList<HMSETResult>>>
First provide a value<T> (value or promiseOf) and get a ValueThenMap. Then pass a mapFunction will return a Promise<R> (property) valueMap_P |
Also, I am not sure how I should interpret this problem:
I think the issue I have opened here is not directly related to this problem but I need to do I think this is related to my #37664 |
My understanding here has not improved 😕 |
I feel like I should be closing this issue until I can explain myself more clearly. |
I must learn how to be more concise it seems. I will use TypeScript the way it is until I can bring my ideas or explain my issues in a more constructive and helpful manner. |
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.9.2 or 4.0.0-dev.20200523 or 3.3.3333
Code
Expected behavior:
I would like to get it expanded like this:
type _P_T<T> = () => T | Promise<T>
should be similar to:

type _PMP_<T> = () => Promise<MaybeList<Promise<T>>>
or should be similar to:

type P_T<T> = T | Promise<T>
Actual behavior:

Not expanding the
P_T
intoT | Promise<T>
the
P_
here is for Promise and all other types I have made in the same module are showingPromise
Keyword expanded except on the line 46~47 (in the playground link below)// expansion: type _P_T<T> = () => P_T<T> should be: type _P_T<T> = () => T | Promise<T>
export type _P_T<T> = () => P_T<T>;
Playground Link:
PlayGround Link v3.9.2
The text was updated successfully, but these errors were encountered: