I would like to use following enum's values:
export enum GenFormats {
SHORT_LOWER = 'm/f', SHORT_UPPER = 'M/F', FULL = 'Male/Female'
};
as type given below:
export interface IGenderOptions {
format: 'm/f' | 'M/F' | 'Male/Female'
};
by using Type extraction/definition something like:
{{some type cast/logic}}<GenFormats> // Outputs: 'm/f' | 'M/F' | 'Male/Female'
Updated Question:
Here is my code:
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
};
My question is, how can I use single entity either enum EGenderFormats or interface IGenderFormats instead of both?
I am using Typescript 3.2.2
Thanks