Method:
get statusEnum(): StatusEnum {
return StatusEnum;
}
Enum:
export enum StatusEnum {
Open = 0,
Edit = 1
}
error: TS2322: Type 'typeof StatusEnum' is not assignable to type 'StatusEnum'.
CodePudding user response:
In case you want to return the whole enum use typeof
keyword:
function getstatusEnum(): typeof StatusEnum {
return StatusEnum;
}
export enum StatusEnum {
Open = 0,
Edit = 1
}
In case you want to return an element from enum
function getstatusEnum(): StatusEnum {
return StatusEnum.Open;
}
export enum StatusEnum {
Open = 0,
Edit = 1
}