Skip to content

Instantly share code, notes, and snippets.

@millsp
Last active February 8, 2021 13:15
Show Gist options
  • Save millsp/7fe06273f9350908b0fdcc025e08eefe to your computer and use it in GitHub Desktop.
Save millsp/7fe06273f9350908b0fdcc025e08eefe to your computer and use it in GitHub Desktop.
class PrismaUser<T> implements PrismaPromise<T> {
[prisma]: true;
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2> {
throw new Error("Method not implemented.");
}
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult> {
throw new Error("Method not implemented.");
}
[Symbol.toStringTag]: string;
finally(onfinally?: (() => void) | null): Promise<T> {
throw new Error("Method not implemented.");
}
}
type PrismaPromise<A> = Promise<A> & {[prisma]: true}
declare const prisma: unique symbol
const $transaction = (arg: PrismaPromise<any>) => { /* CODE */ }
// TEST
declare const regularPromise: Promise<string>
declare const prismaPromise: PrismaPromise<string>
$transaction(regularPromise)
$transaction(prismaPromise)
const awaited = async () => {
const awaitedRegularPromise = await regularPromise
const awaitedPrismaPromise = await prismaPromise
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment