9 lines
235 B
TypeScript
9 lines
235 B
TypeScript
export type Awaitable<T> = Promise<T> | T;
|
|
|
|
export async function interopDefault<T>(
|
|
m: Awaitable<T>,
|
|
): Promise<T extends { default: infer U } ? U : T> {
|
|
const resolved = await m;
|
|
return (resolved as any).default || resolved;
|
|
}
|