You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At #1386, I added basic support for Promise unwrapping. Since then promises have evolved and types like Awaited have been added and a awaited api have been added in the tsc api.
I think the most evident use case is with Prisma, which all ORM methods return a PrismaPromise class:
My current test case of nodes to be supported is the following:
exporttypeOriginal={a: string;b: number[]};exporttypePromiseAlias=Promise<Original>;exportclassPromiseClassextendsPromise<Original>{}exportinterfacePromiseInterfaceextendsPromise<Original>{}exporttypeLikeType=PromiseLike<Original>;exportclassLikeClassimplementsPromiseLike<Original>{then<TResult1=Original,TResult2=never>(onfulfilled?: ((value: Original)=>TResult1|PromiseLike<TResult1>)|null|undefined,onrejected?: ((reason: any)=>TResult2|PromiseLike<TResult2>)|null|undefined): PromiseLike<TResult1|TResult2>{return{}asany;}}exportabstractclassLikeAbstractClassimplementsPromiseLike<Original>{abstractthen<TResult1=Original,TResult2=never>(onfulfilled?: ((value: Original)=>TResult1|PromiseLike<TResult1>)|null|undefined,onrejected?: ((reason: any)=>TResult2|PromiseLike<TResult2>)|null|undefined);}exportinterfaceLikeInterfaceextendsPromiseLike<Original>{}// Prisma has a base promise type just like thisexportinterfaceWithPropertyextendsPromise<Original>{[Symbol.toStringTag]: "WithProperty";}
I'm open to PR it if you want.
The text was updated successfully, but these errors were encountered:
At #1386, I added basic support for
Promise
unwrapping. Since then promises have evolved and types likeAwaited
have been added and a awaited api have been added in the tsc api.I think the most evident use case is with Prisma, which all ORM methods return a
PrismaPromise
class:Every type, just by extending or having the
Promise
as a base type, when used inside aasync function
or within theAwaited
type, gets unwraped:The above example with prisma can be represented in the following way:
checker.getAwaitedType
api exists, but is unfortunately not yet public. https://github.com/nonara/ts-expose-internals can be set up to help us.My current test case of nodes to be supported is the following:
I'm open to PR it if you want.
The text was updated successfully, but these errors were encountered: