Skip to content

Instantly share code, notes, and snippets.

@rodgarcialima
Created July 4, 2020 12:44
Show Gist options
  • Save rodgarcialima/95cd9d9bc34a5757228e211c33c1241c to your computer and use it in GitHub Desktop.
Save rodgarcialima/95cd9d9bc34a5757228e211c33c1241c to your computer and use it in GitHub Desktop.
type CountryCode = keyof typeof Countries;
const countries: Country[] = (Object.keys(Countries) as Array<CountryCode>).map(
(c) => {
const country = Countries[c];
return {
code: c,
name: country.name,
nativeName: country.native,
flag: country.emojiU,
};
}
);
@rodgarcialima
Copy link
Author

declare global {
    interface ObjectConstructor {
        typedKeys<T>(o: T) : Array<keyof T>
    }
}
Object.typedKeys = Object.keys as any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment