Skip to content

Expansion of a generic type with Promise not working in VsCode (and in PlayGroung) 'type X<T> = () => T | Promise<T>;' #38760

@Luxcium

Description

@Luxcium

TypeScript Version: 3.9.2 or 4.0.0-dev.20200523 or 3.3.3333

Code

export const TypeScript = "v3.9.2";

export class MaybeList<T> {
  public constructor(public value: T) {}
}

// type T_<T> = T
export type T_<T> = T;
// type M_<T> = MaybeList<T>
export type M_<T> = T_<MaybeList<T>>;
// type P_<T> = Promise<T>
export type P_<T> = T_<Promise<T>>;
// type MP_<T> = MaybeList<Promise<T>>
export type MP_<T> = M_<P_<T>>;
// type PM_<T> = Promise<MaybeList<T>>
export type PM_<T> = P_<M_<T>>;
// type PMP_<T> = Promise<MaybeList<Promise<T>>>
export type PMP_<T> = P_<M_<P_<T>>> | P_<MP_<T>> | PM_<P_<T>>;
// type P_T<T> = T | Promise<T>
export type P_T<T> =  T | P_<T>;
// type P_M_<T> = MaybeList<T> | Promise<MaybeList<T>>
export type P_M_<T> = (M_<T> | PM_<T>) | P_T<M_<T>>;
// type P_MP_<T> = MaybeList<Promise<T>> | Promise<MaybeList<Promise<T>>>
export type P_MP_<T> = (MP_<T> | PMP_<T>) | P_T<MP_<T>>;

// type _T_<T> = () => T
export type _T_<T> = () => T_<T_<T>>;
// type _M_<T> = () => MaybeList<T>
export type _M_<T> = () => T_<M_<T>>;
// type _P_<T> = () => Promise<T>
export type _P_<T> = () => T_<P_<T>>;
// type _MP_<T> = () => MaybeList<Promise<T>>
export type _MP_<T> = () => T_<MP_<T>>;
// type _PM_<T> = () => Promise<MaybeList<T>>
export type _PM_<T> = () => T_<PM_<T>>;
// type _PMP_<T> = () => Promise<MaybeList<Promise<T>>>
export type _PMP_<T> = () => T_<PMP_<T>>;
// type _P_T<T> = () => P_T<T>
export type _P_T<T> = () => P_T<T>;
// type _P_M_<T> = () => MaybeList<T> | Promise<MaybeList<T>>
export type _P_M_<T> = () => T_<P_M_<T>>;
// type _P_MP_<T> = () => MaybeList<Promise<T>> | Promise<MaybeList<Promise<T>>>
export type _P_MP_<T> = () => T_<P_MP_<T>>;

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>>>
image

or should be similar to: type P_T<T> = T | Promise<T>
image

Actual behavior:
Not expanding the P_T into T | Promise<T>
image

the P_ here is for Promise and all other types I have made in the same module are showing Promise 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions