From 2c2fabb7dc269427b7977fd35278614c3e43ddcb Mon Sep 17 00:00:00 2001 From: hcwhan Date: Wed, 30 Nov 2022 20:43:45 +0800 Subject: [PATCH] feat: add-instanceType-option --- src/core/declaration.ts | 11 +++++++++++ src/types.ts | 6 ++++++ 2 files changed, 17 insertions(+) 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