www.un.org/Depts/DGACM/index_french.htm 载于<>Express内的类型:
type SerializedFunction<Serialized, Unserialized>
= <B extends boolean>(serialize: B)
=> Promise<B extends true
? (Serialized | null)
: (Unserialized | null)
>;
附属于以下职能:
import type { examples } from "@prisma/client";
interface DataSerialized{
foo: string;
bar: number;
}
const data: SerializedFunction<DataSerialized, examples> = async serialize => {
// Return non-serialized data.
if(!serialized) return await prisma.examples.findFirst({
// ...
});
const example = await prisma.examples.findFirst({
// ...
select: {
foo: true,
bar: true,
}
});
if(!example) return null;
return {
...example,
bar: await doSomethingWithBar(bar)
};
}
然而,在我试图落实这一点时,我收到以下<>捷潘普文斯特隆>错误: 在什么地方我错了?Type examples | {
// The object specified in the first "findFirst" call...
}
is not assignable to type B extends true ? DataSerialized : examples .
Type examples is not assignable to type B extends true ? DataSerialized : examples