Browse Source

fix: avoid union types to be imported in schematics

pull/5137/head
Arman Ozak 6 years ago
parent
commit
0c9c5da87d
  1. 12
      npm/ng-packs/packages/schematics/src/utils/model.ts

12
npm/ng-packs/packages/schematics/src/utils/model.ts

@ -84,7 +84,17 @@ export function mergeBaseTypeWithProperties({ baseType, genericArguments, proper
const baseTypes = baseType ? [baseType] : [];
const propTypes = (properties ?? []).map(({ type }) => type);
return [...baseTypes, ...propTypes].map(removeGenerics);
return [...baseTypes, ...propTypes].reduce(flattenUnionTypes, []).map(removeGenerics);
}
export function flattenUnionTypes(types: string[], type: string) {
type
.replace(/^{/, '')
.replace(/}$/, '')
.split(':')
.forEach(t => types.push(t));
return types;
}
export function createGenericRemover(genericArguments: string[] | null) {

Loading…
Cancel
Save