@@ -65,6 +65,9 @@ export const builder = (yargs: *): void => {
6565 } ) ;
6666} ;
6767
68+ type ColumnFilterType = ( tableName : string , columnName : string ) = > boolean ;
69+ type FormatterType = ( name : string ) => string ;
70+
6871export const handler = async ( argv : ConfigurationType ) : Promise < void > => {
6972 const defaultFormatTypeName = ( tableName : string ) : string => {
7073 return _ . upperFirst ( _ . camelCase ( tableName ) ) + 'RecordType' ;
@@ -74,9 +77,13 @@ export const handler = async (argv: ConfigurationType): Promise<void> => {
7477 return _ . camelCase ( columnName ) ;
7578 } ;
7679
77- const filterColumns = argv . columnFilter ? new Function ( 'tableName' , 'columnName' , argv . columnFilter ) : null ;
78- const formatTypeName = argv . typeNameFormatter ? new Function ( 'columnName' , argv . typeNameFormatter ) : defaultFormatTypeName ;
79- const formatPropertyName = argv . propertyNameFormatter ? new Function ( 'tableName' , argv . propertyNameFormatter ) : defaultFormatPropertyName ;
80+ // eslint-disable-next-line no-extra-parens
81+ const filterColumns : ColumnFilterType = ( argv . columnFilter ? new Function ( 'tableName' , 'columnName' , argv . columnFilter ) : null : any ) ;
82+
83+ // eslint-disable-next-line no-extra-parens
84+ const formatTypeName : FormatterType = ( argv . typeNameFormatter ? new Function ( 'columnName' , argv . typeNameFormatter ) : defaultFormatTypeName : any ) ;
85+ // eslint-disable-next-line no-extra-parens
86+ const formatPropertyName : FormatterType = ( argv . propertyNameFormatter ? new Function ( 'tableName' , argv . propertyNameFormatter ) : defaultFormatPropertyName : any ) ;
8087
8188 const createProperties = ( columns : $ReadOnlyArray < ColumnType > ) : $ReadOnlyArray < TypePropertyType > => {
8289 let filteredColumns = columns ;
@@ -89,13 +96,9 @@ export const handler = async (argv: ConfigurationType): Promise<void> => {
8996 }
9097
9198 return filteredColumns . map ( ( column ) => {
92- // $FlowFixMe
9399 return {
94- // $FlowFixMe
95100 name : formatPropertyName ( column . columnName ) ,
96101 type : mapFlowType ( column . databaseType ) + ( column . nullable ? ' | null' : '' ) ,
97-
98- // $FlowFixMe
99102 typeName : formatTypeName ( column . tableName )
100103 } ;
101104 } ) ;
0 commit comments