Browse Source

fix: check list types before splitting them in schematics

pull/5137/head
Arman Ozak 6 years ago
parent
commit
61cc1f6604
  1. 31
      npm/ng-packs/packages/schematics/src/utils/type.ts

31
npm/ng-packs/packages/schematics/src/utils/type.ts

@ -11,17 +11,26 @@ export function createTypeSimplifier(solution: string) {
const solutionRegex = new RegExp(solution.replace(/\./g, `\.`) + `\.`); const solutionRegex = new RegExp(solution.replace(/\./g, `\.`) + `\.`);
const voloRegex = /^Volo\.(Abp\.?)(Application\.?)/; const voloRegex = /^Volo\.(Abp\.?)(Application\.?)/;
return (type: string) => { return (originalType: string) => {
type = type.replace(voloRegex, ''); const union = originalType
type = type.replace(solutionRegex, ''); .replace(/^{/, '')
type = type.replace(optionalRegex, ''); .replace(/}$/, '')
type = type.replace( .split(':');
/System\.([0-9A-Za-z]+)/g, return union
(_, match) => SYSTEM_TYPES.get(match) ?? strings.camelize(match), .map(type => {
); type = type.startsWith('[') ? type.slice(1, -1) + '[]' : type;
type = type.split('.').pop()!; type = type.replace(voloRegex, '');
type = type.startsWith('[') ? type.slice(1, -1) + '[]' : type; type = type.replace(solutionRegex, '');
return type; type = type.replace(optionalRegex, '');
type = type.replace(
/System\.([0-9A-Za-z]+)/g,
(_, match) => SYSTEM_TYPES.get(match) ?? strings.camelize(match),
);
type = type.split('.').pop()!;
console.log(type);
return type;
})
.join(' | ');
}; };
} }

Loading…
Cancel
Save