From bbb7bdc7cb957cc5614a4c0c2aa67db8dcfabaa7 Mon Sep 17 00:00:00 2001 From: YinChang0626 Date: Sun, 15 Nov 2020 15:11:53 +0800 Subject: [PATCH 1/2] fix(@abp/ng.schematics) :resolve #6144 (cherry picked from commit 3561453a11f56d257aef2c47d03094d185d8792e) --- .../packages/schematics/src/utils/type.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/utils/type.ts b/npm/ng-packs/packages/schematics/src/utils/type.ts index 25751f475d..057966cba0 100644 --- a/npm/ng-packs/packages/schematics/src/utils/type.ts +++ b/npm/ng-packs/packages/schematics/src/utils/type.ts @@ -13,7 +13,16 @@ export function createTypeSimplifier() { /System\.([0-9A-Za-z.]+)/g, (_, match) => SYSTEM_TYPES.get(match) ?? strings.camelize(match), ); - return type.split('.').pop()!; + + let regexp = new RegExp(/.*(?<=\.)(?.+)<.*(?<=[\.<])(?.+)>/gm); + let groups=regexp.exec(type)?.groups; + + if(!groups?.generic){ + return type.split('.').pop()!; + } + else{ + return `${groups?.generic}<${groups?.genericType}>` + } }); return (type: string) => { @@ -95,8 +104,8 @@ export function createTypeToImportMapper(solution: string, namespace: string) { const path = VOLO_REGEX.test(type) ? '@abp/ng.core' : isEnum - ? relativePathToEnum(namespace, modelNamespace, specifiers[0]) - : relativePathToModel(namespace, modelNamespace); + ? relativePathToEnum(namespace, modelNamespace, specifiers[0]) + : relativePathToModel(namespace, modelNamespace); return new Import({ keyword: eImportKeyword.Type, path, refs, specifiers }); }; From 4330b406c6f1379ac633dc8d6d40a44e8e6e490f Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 19 Nov 2020 14:51:59 +0300 Subject: [PATCH 2/2] fix: avoid lint error and optimize --- .../packages/schematics/src/utils/type.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/utils/type.ts b/npm/ng-packs/packages/schematics/src/utils/type.ts index 057966cba0..9e1d6a8ea9 100644 --- a/npm/ng-packs/packages/schematics/src/utils/type.ts +++ b/npm/ng-packs/packages/schematics/src/utils/type.ts @@ -9,20 +9,16 @@ import { parseGenerics } from './tree'; export function createTypeSimplifier() { const parseType = createTypeParser(type => { + const regexp = new RegExp(/.*(?<=\.)(?.+)<.*(?<=[\.<])(?.+)>/gm); + const { generic, genericType } = regexp.exec(type)?.groups ?? {}; + + if (generic) return `${generic}<${genericType}>`; + type = type.replace( /System\.([0-9A-Za-z.]+)/g, (_, match) => SYSTEM_TYPES.get(match) ?? strings.camelize(match), ); - - let regexp = new RegExp(/.*(?<=\.)(?.+)<.*(?<=[\.<])(?.+)>/gm); - let groups=regexp.exec(type)?.groups; - - if(!groups?.generic){ - return type.split('.').pop()!; - } - else{ - return `${groups?.generic}<${groups?.genericType}>` - } + return type.split('.').pop()!; }); return (type: string) => { @@ -104,8 +100,8 @@ export function createTypeToImportMapper(solution: string, namespace: string) { const path = VOLO_REGEX.test(type) ? '@abp/ng.core' : isEnum - ? relativePathToEnum(namespace, modelNamespace, specifiers[0]) - : relativePathToModel(namespace, modelNamespace); + ? relativePathToEnum(namespace, modelNamespace, specifiers[0]) + : relativePathToModel(namespace, modelNamespace); return new Import({ keyword: eImportKeyword.Type, path, refs, specifiers }); };