33const fs = require ( 'fs-extra' ) ;
44const path = require ( 'path' ) ;
55
6+ const componentSvelteElementInheritance = {
7+ Button : 'HTMLButtonAttributes' ,
8+ Link : 'HTMLAnchorAttributes' ,
9+ } ;
10+
611const componentNativeElementInheritance = {
712 Actions : 'HTMLDivElement' ,
813 ActionsButton : 'HTMLButtonElement' ,
@@ -18,13 +23,11 @@ const componentNativeElementInheritance = {
1823 BreadcrumbsCollapsed : 'HTMLDivElement' ,
1924 BreadcrumbsItem : 'HTMLDivElement' ,
2025 BreadcrumbsSeparator : 'HTMLDivElement' ,
21- Button : 'HTMLButtonElement' ,
2226 Card : 'HTMLDivElement' ,
2327 Checkbox : 'HTMLLabelElement' ,
2428 Chip : 'HTMLDivElement' ,
2529 Fab : 'HTMLAnchorElement' ,
2630 Icon : 'HTMLElement' ,
27- Link : 'HTMLAnchorElement' ,
2831 List : 'HTMLDivElement' ,
2932 ListButton : 'HTMLLIElement' ,
3033 ListGroup : 'HTMLLIElement' ,
@@ -125,9 +128,15 @@ const createComponentTypes = (componentName, propsContent) => {
125128 } )
126129 . join ( '\n' ) ;
127130 const slotsContent = slots . map ( ( slot ) => `'${ slot } ': {};` ) . join ( '\n ' ) ;
131+ const svelteElementType = componentSvelteElementInheritance [ componentName ] ;
132+ const nativeElementType = componentNativeElementInheritance [ componentName ] ;
128133 return `
129134import { SvelteComponent } from 'svelte';
130- import { HTMLAttributes } from 'svelte/elements';
135+ ${
136+ svelteElementType
137+ ? `import type { ${ svelteElementType } } from 'svelte/elements';`
138+ : `import { HTMLAttributes } from 'svelte/elements';`
139+ }
131140
132141${ propsContent }
133142
@@ -137,9 +146,11 @@ interface ${componentName}Events extends Record<'',{}>{}
137146
138147declare class ${ componentName } extends SvelteComponent<
139148 ${ componentName } Props${
140- componentNativeElementInheritance [ componentName ]
141- ? ` & HTMLAttributes<${ componentNativeElementInheritance [ componentName ] } >`
142- : ''
149+ svelteElementType
150+ ? ` & ${ svelteElementType } `
151+ : nativeElementType
152+ ? ` & HTMLAttributes<${ nativeElementType } >`
153+ : ''
143154 } ,
144155 ${ componentName } Events,
145156 {
0 commit comments