@@ -18,6 +18,12 @@ export const generateComponentTypes = (
1818) : d . TypesModule => {
1919 const tagName = cmp . tagName . toLowerCase ( ) ;
2020 const tagNameAsPascal = dashToPascalCase ( tagName ) ;
21+ const classTypeParams =
22+ cmp . componentClassTypeParameters . length > 0 ? `<${ cmp . componentClassTypeParameters . join ( ',' ) } >` : '' ;
23+ const classTypeParamsAny =
24+ cmp . componentClassTypeParameters . length > 0
25+ ? `<${ cmp . componentClassTypeParameters . map ( ( ) => 'any' ) . join ( ',' ) } >`
26+ : '' ;
2127 const htmlElementName = `HTML${ tagNameAsPascal } Element` ;
2228
2329 const propAttributes = generatePropTypes ( cmp , typeImportData ) ;
@@ -33,20 +39,19 @@ export const generateComponentTypes = (
3339 const jsxAttributes = attributesToMultiLineString ( [ ...propAttributes , ...eventAttributes ] , true , areTypesInternal ) ;
3440
3541 const element = [
36- ` interface ${ htmlElementName } extends Components.${ tagNameAsPascal } , HTMLStencilElement {` ,
42+ ` interface ${ htmlElementName } ${ classTypeParams } extends Components.${ tagNameAsPascal } ${ classTypeParams } , HTMLStencilElement {` ,
43+ ` prototype: ${ htmlElementName } ${ classTypeParams } ;` ,
44+ ` new (): ${ htmlElementName } ${ classTypeParams } ;` ,
3745 ` }` ,
38- ` var ${ htmlElementName } : {` ,
39- ` prototype: ${ htmlElementName } ;` ,
40- ` new (): ${ htmlElementName } ;` ,
41- ` };` ,
46+ ` var ${ htmlElementName } : ${ htmlElementName } ${ classTypeParamsAny } ;` ,
4247 ] ;
4348 return {
4449 isDep,
4550 tagName,
46- tagNameAsPascal,
47- htmlElementName,
48- component : ` interface ${ tagNameAsPascal } {\n${ componentAttributes } }` ,
49- jsx : ` interface ${ tagNameAsPascal } {\n${ jsxAttributes } }` ,
51+ tagNameAsPascal : ` ${ tagNameAsPascal } ${ classTypeParamsAny } ` ,
52+ htmlElementName : ` ${ htmlElementName } ${ classTypeParamsAny } ` ,
53+ component : ` interface ${ tagNameAsPascal } ${ classTypeParams } {\n${ componentAttributes } }` ,
54+ jsx : ` interface ${ tagNameAsPascal } ${ classTypeParams } {\n${ jsxAttributes } }` ,
5055 element : element . join ( `\n` ) ,
5156 } ;
5257} ;
0 commit comments