remove unnecessary parentheses and duplicate types (#2204)

* remove unnecessary parentheses and duplicate types

* fix: remove test code
This commit is contained in:
Jeremías Díaz
2020-04-24 15:28:47 +02:00
committed by GitHub
parent 63732f1456
commit 5a929d3810
4 changed files with 16 additions and 9 deletions
@@ -20,6 +20,7 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
const imports = createImports(importDefinitions);
const definitions = imports.definitions;
const primitives = Object
.keys(primitiveClasses)
.filter((name): boolean => !!name.indexOf('Generic'))
@@ -32,13 +33,19 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
].join('\n');
}, '');
const existingTypes: Record<string, boolean> = {};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const srml = Object.entries(definitions).reduce((accumulator, [_defName, { types }]): string => {
setImports(definitions, imports, Object.keys(types));
const uniqueTypes = Object.keys(types).filter((type) => !existingTypes[type]);
uniqueTypes.forEach((type) => { existingTypes[type] = true; });
return [
accumulator,
...Object.keys(types).map((type): string =>
...uniqueTypes.map((type): string =>
getDerivedTypes(definitions, type, types[type], imports).map(indent(4)).join('\n')
)
].join('\n');
+1 -1
View File
@@ -27,7 +27,7 @@ import { formatType } from './formatting';
import { setImports, TypeImports } from './imports';
function arrayToStrType (arr: string[]): string {
return `(${arr.map((c): string => `'${c}'`).join(' | ')})`;
return `${arr.map((c): string => `'${c}'`).join(' | ')}`;
}
const voteConvictions = arrayToStrType(AllConvictions);