Skip to content

Commit 221c641

Browse files
committed
feat(component-type-helpers): add ComponentAttrs type for attribute extraction
1 parent 4b8a4a2 commit 221c641

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/component-type-helpers/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export type ComponentSlots<T> =
1313
T extends (props: any, ctx: { slots: infer S; attrs: any; emit: any; }, ...args: any) => any ? NonNullable<S> :
1414
{};
1515

16+
export type ComponentAttrs<T> =
17+
T extends new (...args: any) => { $attrs: infer A; } ? NonNullable<A> :
18+
T extends (props: any, ctx: { slots: any; attrs: infer A; emit: any; }, ...args: any) => any ? NonNullable<A> :
19+
{};
20+
1621
export type ComponentEmit<T> =
1722
T extends new (...args: any) => { $emit: infer E; } ? NonNullable<E> :
1823
T extends (props: any, ctx: { slots: any; attrs: any; emit: infer E; }, ...args: any) => any ? NonNullable<E> :

0 commit comments

Comments
 (0)