type Test<T> = [T] extends [never] ? "never" : T extends object ? "object" : T;
type Test2<T> = [T] extends [never] ? "never" : T extends object ? "object" : "other";
export async function initPlatform1<extraCtx extends object = never>(
modules: any[],
ctx: Test<extraCtx>,
) {}
export async function initPlatform2<extraCtx extends object = never>(
modules: any[],
ctx: Test2<extraCtx>,
) {}
initPlatform1([], {
timezone: 'Asia/Shanghai',
});
initPlatform2([], {
timezone: 'Asia/Shanghai',
});
This is my code, why is the function signature of initPlatform1
function initPlatform1<{
timezone: string;
}>(modules: any[], ctx: "object"): Promise<void>
while initPlatform2 is
function initPlatform2<never>(modules: any[], ctx: "never"): Promise<void>