diff --git a/src/core/declaration.ts b/src/core/declaration.ts index c3f67786..de3d61ac 100644 --- a/src/core/declaration.ts +++ b/src/core/declaration.ts @@ -142,6 +142,17 @@ ${head}` }` } code += '\n}\n' + + if (ctx.options.instanceType) { + if (Object.keys(declarations.component).length > 0) { + const instanceTypes = declarations.component.map(str => `type ${str.replace(': typeof import', 'Instance = InstanceType`) + code += ` +declare global { + ${instanceTypes.join('\n ')} +}\n` + } + } + return code } diff --git a/src/types.ts b/src/types.ts index f8d52c0e..21d091d0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -149,6 +149,12 @@ export interface Options { */ dts?: boolean | string + /** + * Generate TypeScript declaration for components InstanceType. + * @default false + */ + instanceType?: boolean + /** * Do not emit warning on component overriding * pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy