Skip to content

ModuleExports

Infers the exported members of a module based on its descriptor.

D - The module descriptor, which may specify a default export (as a string) and/or an array of named exports (named).

If D includes a default property of type string, the resulting type will include a default property of type Refkey. If D includes a named property (an array of NamedModuleDescriptor), the resulting type will include the mapped named exports as defined by NamedMap.

export type ModuleExports<D extends { default?: string; named?: NamedModuleDescriptor[]; }> = (D extends { default: string; } ? { default: Refkey; } : {}) & (D[“named”] extends NamedModuleDescriptor[] ? NamedMap<D[“named”]> : {});