I want to implement the values of the following enum
:
export enum GenderFormats {
SHORT_LOWER = 'm/f', SHORT_UPPER = 'M/F', FULL = 'Male/Female'
};
as a type shown below:
export interface IGenderOptions {
format: 'm/f' | 'M/F' | 'Male/Female'
};
using Type extraction/definition like this:
{{some type cast/logic}}<GenFormats> // Outputs: 'm/f' | 'M/F' | 'Male/Female'
Revised Question:
This is my code snippet:
export enum EGenderFormats {
SHORT_LOWER = 'm/f', SHORT_UPPER = 'M/F', FULL = 'Male/Female'
};
export interface IGenderFormats {
SHORT_LOWER: 'm/f'; SHORT_UPPER: 'M/F'; FULL: 'Male/Female';
};
export interface IGenderOptions {
format: IGenderFormats[keyof IGenderFormats]
};
const DEFAULTS: IGenderOptions = {
format: EGenderFormats.FULL
};
How can I utilize either enum EGenderFormats
or interface IGenderFormats
instead of both?
Running Typescript 3.2.2
Thank you