From afc6454ea7b9acca3154b8554924fb84e8bc14c9 Mon Sep 17 00:00:00 2001 From: sumeyye Date: Tue, 11 Feb 2025 11:40:42 +0300 Subject: [PATCH] update: readability --- npm/ng-packs/packages/schematics/src/utils/model.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/utils/model.ts b/npm/ng-packs/packages/schematics/src/utils/model.ts index a46eff612d..c1d8423c58 100644 --- a/npm/ng-packs/packages/schematics/src/utils/model.ts +++ b/npm/ng-packs/packages/schematics/src/utils/model.ts @@ -187,10 +187,12 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) { } function isOptionalProperty(prop: PropertyDef) { - return ( - prop.typeSimple.endsWith('?') || - ((prop.typeSimple === 'string' || prop.typeSimple.includes('enum')) && !prop.isRequired) - ); + const { isRequired, typeSimple } = prop; + if (typeSimple === 'string' || typeSimple.includes('enum')) { + return !isRequired; + } else { + return typeSimple.endsWith('?'); + } } export function parseBaseTypeWithGenericTypes(type: string): string[] {