You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an issue tracker, not a standard help forum. But anyways, here's how you'd do it:
// This requires TypeScript 2.1.// If you need older versions, use `string` instead of `keyof E`.interfaceEnumItem<E>{id: E;name: keyofE;}functionenumToArray<E>(Enum: {[keyofE]: E}): EnumItem<E>[]{returnObject.keys(Enum).map(key=>({id: Enum[key],name: key}asEnumItem<E>))}
I want convert enum type to Array.
example :
enum A {
dog = 1,
cat = 2,
ant = 3
}
convert to: [{id: 1, name: 'dog'}, {id: 2, name: 'cat'}, {id: 3, name: 'ant'}]
thank you.
The text was updated successfully, but these errors were encountered: