Skip to content

Commit 4b4e3c7

Browse files
authored
Merge pull request #22120 from abpframework/issue-22118
Angular - Fixing nullability and type problems while generating proxy
2 parents 69817b3 + e996cf9 commit 4b4e3c7

File tree

1 file changed

+10
-2
lines changed
  • npm/ng-packs/packages/schematics/src/utils

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP
148148
typeDef.properties?.forEach(prop => {
149149
let name = prop.jsonName || camel(prop.name);
150150
name = shouldQuote(name) ? `'${name}'` : name;
151-
const type = simplifyType(prop.type);
151+
152+
let type = simplifyType(prop.typeSimple);
153+
if (prop.typeSimple.includes('enum')) {
154+
type = simplifyType(prop.type);
155+
}
156+
152157
const refs = parseType(prop.type).reduce(
153158
(acc: string[], r) => acc.concat(parseGenerics(r).toGenerics()),
154159
[],
@@ -182,7 +187,10 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) {
182187
}
183188

184189
function isOptionalProperty(prop: PropertyDef) {
185-
return prop.typeSimple.endsWith('?') || (prop.typeSimple === 'string' && !prop.isRequired);
190+
return (
191+
prop.typeSimple.endsWith('?') ||
192+
((prop.typeSimple === 'string' || prop.typeSimple.includes('enum')) && !prop.isRequired)
193+
);
186194
}
187195

188196
export function parseBaseTypeWithGenericTypes(type: string): string[] {

0 commit comments

Comments
 (0)