P
Prisma3mo ago
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) => {
}
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'.
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
tx: as unknown as Prisma.TransactionClient
1 Reply
mabasic
mabasic2mo ago
GitHub
Prisma client extensions: return type of recordversion.findUnique...
Bug description After update to 4.16.x (observed on all tested versions tested so far from 4.16.0 through to 4.16.2-dev.2), an extended prisma client is considered to have an incompatible type for ...
Want results from more Discord servers?
Add your server