File tree 1 file changed +10
-2
lines changed
npm/ng-packs/packages/schematics/src/utils
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,12 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP
148
148
typeDef . properties ?. forEach ( prop => {
149
149
let name = prop . jsonName || camel ( prop . name ) ;
150
150
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
+
152
157
const refs = parseType ( prop . type ) . reduce (
153
158
( acc : string [ ] , r ) => acc . concat ( parseGenerics ( r ) . toGenerics ( ) ) ,
154
159
[ ] ,
@@ -182,7 +187,10 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) {
182
187
}
183
188
184
189
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
+ ) ;
186
194
}
187
195
188
196
export function parseBaseTypeWithGenericTypes ( type : string ) : string [ ] {
You can’t perform that action at this time.
0 commit comments