7 lines
227 B
TypeScript
7 lines
227 B
TypeScript
export type Awaitable<T> = T | Promise<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
|
|
}
|