File tree Expand file tree Collapse file tree
projects/angular-odata/schematics/apigen/angular Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ export class EntityProperty {
2828 if ( enumType !== undefined ) {
2929 type = enumType . importedName ( imports ) ! ;
3030 type += this . edmType . Collection ? '[]' : '' ;
31+ if ( ! this . edmType . Collection && enumType . isFlags ( ) && ! enumType . hasValue ( 0 ) ) {
32+ type += ' | 0' ;
33+ }
3134 } else if ( entityType !== undefined ) {
3235 type = entityType . importedName ( imports ) ! ;
3336 type += this . edmType . Collection ? '[]' : '' ;
Original file line number Diff line number Diff line change @@ -47,9 +47,12 @@ export class Enum extends Base {
4747 public members ( ) {
4848 return this . edmType . Member . map ( ( m ) => `${ m . Name } = ${ m . Value } ` ) ;
4949 }
50- public flags ( ) {
50+ public isFlags ( ) {
5151 return this . edmType . IsFlags ;
5252 }
53+ public hasValue ( value : number ) {
54+ return this . edmType . Member . some ( m => m . Value === value ) ;
55+ }
5356 public override importTypes ( ) : string [ ] {
5457 return [ ] ;
5558 }
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ export class ModelField {
3030 if ( enumType !== undefined ) {
3131 type = enumType . importedName ( imports ) ! ;
3232 type += this . edmType . Collection ? '[]' : '' ;
33+ if ( ! this . edmType . Collection && enumType . isFlags ( ) && ! enumType . hasValue ( 0 ) ) {
34+ type += ' | 0' ;
35+ }
3336 } else if ( entityType !== undefined ) {
3437 if ( this . edmType . Collection ) {
3538 const collection = pkg . findCollection ( this . edmType . Type ) ;
You can’t perform that action at this time.
0 commit comments