@@ -8,8 +8,8 @@ import { snakeCaseToPascalCase } from '@/utils/strings';
88import { cleanOrCreateDirectory , printSourceFile } from './shared/utils' ;
99import {
1010 ConfigurationClassName ,
11- PropertyClassName ,
1211 PropertyComponentsClassesPath ,
12+ PropertyTypeName ,
1313} from './shared/constants' ;
1414import * as tsUtils from './shared/typescript' ;
1515
@@ -55,7 +55,7 @@ function createConstructorDeclaration({ name }: PropertyComponent) {
5555 undefined ,
5656 ts . factory . createTypeReferenceNode ( ts . factory . createIdentifier ( 'Readonly' ) , [
5757 ts . factory . createTypeReferenceNode (
58- ts . factory . createIdentifier ( PropertyClassName ) ,
58+ ts . factory . createIdentifier ( PropertyTypeName ) ,
5959 undefined ,
6060 ) ,
6161 ] ) ,
@@ -79,11 +79,8 @@ function createDataComponentValueTypeDefinitionOverride() {
7979 [
8080 ts . factory . createReturnStatement (
8181 ts . factory . createPropertyAccessExpression (
82- ts . factory . createPropertyAccessExpression (
83- ts . factory . createThis ( ) ,
84- ts . factory . createIdentifier ( 'property' ) ,
85- ) ,
86- ts . factory . createIdentifier ( 'definition' ) ,
82+ ts . factory . createThis ( ) ,
83+ ts . factory . createIdentifier ( 'property' ) ,
8784 ) ,
8885 ) ,
8986 ] ,
@@ -192,8 +189,8 @@ function printPropertyComponentClassDefinition(filename: string, classDeclaratio
192189
193190 const nodes = [
194191 [
195- printer ( tsUtils . createImportDeclaration ( `../configuration ` , ConfigurationClassName ) ) ,
196- printer ( tsUtils . createImportDeclaration ( `../core/ ${ PropertyClassName } ` , PropertyClassName ) ) ,
192+ printer ( tsUtils . createImportDeclaration ( `../core/Configuration ` , ConfigurationClassName ) ) ,
193+ printer ( tsUtils . createImportDeclaration ( `../types ` , PropertyTypeName ) ) ,
197194 printer ( tsUtils . createImportDeclaration ( `../core/${ BaseClassName } ` , BaseClassName ) ) ,
198195 ]
199196 . join ( '\n' )
@@ -213,14 +210,23 @@ function printPropertyComponentsMetaData(classNames: string[], components: Prope
213210 . map ( ( className ) => printer ( tsUtils . createImportDeclaration ( `./${ className } ` , className ) ) )
214211 . join ( '\n' )
215212 . concat ( '\n' ) ,
213+ printer ( tsUtils . createImportDeclaration ( `./types` , ComponentNameTypeName ) ) . concat ( '\n\n' ) ,
216214 printer ( createPropertyComponentClassMapDefinition ( components ) ) . concat ( '\n' ) ,
217215 printer ( createPropertyComponentMapDefinition ( components ) ) . concat ( '\n' ) ,
218- printer ( createPropertyComponentNameDeclaration ( components ) ) ,
219216 ] ;
220217
221218 printSourceFile ( filename , nodes ) ;
222219}
223220
221+ function printPropertyComponentsTypes ( components : PropertyComponents ) {
222+ const filename = path . join ( PropertyComponentsClassesPath , `types.ts` ) ;
223+ const printer = tsUtils . createPrinter ( filename ) ;
224+
225+ const nodes = [ printer ( createPropertyComponentNameDeclaration ( components ) ) ] ;
226+
227+ printSourceFile ( filename , nodes ) ;
228+ }
229+
224230function printExportDefinitionsForPropertyComponents ( classNames : string [ ] ) {
225231 const filename = path . join ( PropertyComponentsClassesPath , `index.ts` ) ;
226232 const printer = tsUtils . createPrinter ( filename ) ;
@@ -257,6 +263,7 @@ function generatePropertyComponents() {
257263
258264 printExportDefinitionsForPropertyComponents ( classNames ) ;
259265 printPropertyComponentsMetaData ( classNames , components ) ;
266+ printPropertyComponentsTypes ( components ) ;
260267
261268 console . log ( 'Successfully generated property components.' ) ;
262269}
0 commit comments