Skip to content

Commit ceb9ea4

Browse files
committed
style: avoid $FlowFixMe
1 parent a326f70 commit ceb9ea4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/bin/commands/generate-types.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
6871
export 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

Comments
 (0)