PrismaP
Prisma2y ago
2 replies
Hinky

Argument transaction tx with prisma accerlate typescript error

Yo yo,

so i have a very long transaction that i am wanting to break up, just for easier maintance. So i want to pass the transaction func as argument however i am getting typescript type mismatch. ( am guessing because of prisma accerlate)

example:
const trans = await prisma.$transaction(async (tx) => {
            const isTransaction = await exampleFuncUsingTx(tx);
        });


const exampleFuncUsingTx = async (tx: Prisma.TransactionClient) => {
}



Doing above, ill get this error:
Argument of type 'Omit<DynamicClientExtensionThis<TypeMap<InternalArgs<{ [x: string]: { [x: string]: unknown; }; }, { [x: string]: { [x: string]: unknown; }; }, { [x: string]: { [x: string]: unknown; }; }, { [x: string]: unknown; }> & { result: {}; model: { $allModels: { ...; }; ... 56 more ...; zzz_invoice: { ...; }; }; query: {}; c...' is not assignable to parameter of type 'TransactionClient'.
  The types of 'log.findUnique' are incompatible between these types.
    Type '<T_5, A_5>(this: T_5, args: Exact<A_5, Args<T_5, "findUnique"> & PrismaCacheStrategy>) => AcceleratePromise<Result<T_5, A_5, "findUnique"> | null>' is not assignable to type '<T extends logFindUniqueArgs<DefaultArgs>>(args: SelectSubset<T, logFindUniqueArgs<DefaultArgs>>) => Prisma__logClient<...>'.
      Types of parameters 'args' and 'args' are incompatible.
        Type 'SelectSubset<T, logFindUniqueArgs<DefaultArgs>>' is not assignable to type 'Exact<T, any>'.
          Type 'SelectSubset<T, logFindUniqueArgs<DefaultArgs>>' is not assignable to type 'T extends Narrowable ? T : never'.


I suppose my main question, is it safe for me to just make this assumption?
tx:  as unknown as Prisma.TransactionClient
Was this page helpful?