@@ -24,6 +24,7 @@ type IComponent = {
2424} & {
2525 nestedComponents ?: INestedComponent [ ] ;
2626 configComponentPath ?: string ;
27+ containsReexports ?: boolean
2728} ;
2829
2930interface INestedComponent {
@@ -167,6 +168,7 @@ const renderModule: (model: {
167168 renderedNestedComponents ?: string [ ] ;
168169 defaultExport : string ;
169170 renderedExports : string ;
171+ renderedReExports ?: string ;
170172} ) => string = createTempate (
171173 '<#= it.renderedImports #>\n'
172174
@@ -186,7 +188,10 @@ const renderModule: (model: {
186188+ `export {
187189<#= it.renderedExports #>
188190};
189- ` ,
191+ `
192+ + '<#? it.renderedReExports #>'
193+ + '<#= it.renderedReExports #>\n\n'
194+ + '<#?#>' ,
190195) ;
191196
192197const renderImports : ( model : {
@@ -402,6 +407,11 @@ function renderExports(exportsNames: string[]) {
402407 . join ( ',\n' ) ;
403408}
404409
410+ function renderReExports ( componentName : string , exportPath : string ) {
411+ return `import type * as ${ componentName } Types from '${ exportPath } _types';\n`
412+ + `export { ${ componentName } Types };` ;
413+ }
414+
405415function formatTemplatePropName ( name : string , suffix : string ) : string {
406416 return lowercaseFirst ( name . replace ( / t e m p l a t e $ / i, suffix ) ) ;
407417}
@@ -441,7 +451,7 @@ function createPropTypingModel(typing: IPropTyping): IRenderedPropTyping {
441451 } ;
442452}
443453
444- function generate ( component : IComponent ) : string {
454+ function generate ( component : IComponent , generateReexports = false ) : string {
445455 const nestedComponents = component . nestedComponents
446456 ? component . nestedComponents
447457 . sort ( createKeyComparator < INestedComponent > ( ( o ) => o . className ) )
@@ -549,6 +559,8 @@ function generate(component: IComponent): string {
549559 . map ( ( t ) => renderPropTyping ( createPropTypingModel ( t ) ) )
550560 : undefined ;
551561
562+ const hasExplicitTypes = ! ! component . optionsTypeParams ?. length ;
563+
552564 return renderModule ( {
553565
554566 renderedImports : renderImports ( {
@@ -561,7 +573,7 @@ function generate(component: IComponent): string {
561573 optionsAliasName : hasExtraOptions ? undefined : optionsName ,
562574 hasExtraOptions,
563575 hasPropTypings : isNotEmptyArray ( renderedPropTypings ) ,
564- hasExplicitTypes : ! ! component . optionsTypeParams ?. length ,
576+ hasExplicitTypes,
565577 configComponentPath : isNotEmptyArray ( nestedComponents )
566578 ? component . configComponentPath
567579 : undefined ,
@@ -598,6 +610,9 @@ function generate(component: IComponent): string {
598610
599611 defaultExport : component . name ,
600612 renderedExports : renderExports ( exportNames ) ,
613+ renderedReExports : generateReexports && component . containsReexports
614+ ? renderReExports ( component . name , component . dxExportPath )
615+ : undefined ,
601616 } ) ;
602617}
603618
0 commit comments