Skip to content

Instantly share code, notes, and snippets.

View janjakubnanista's full-sized avatar

Ján Jakub Naništa janjakubnanista

  • LayerZero
  • Vancouver
View GitHub Profile
{
"image": "https://images.ctfassets.net/a9237abdyvg9/2GDeLs0jA3u3jHJsIlBTGT/d06c08a6f7a8e1bbdb34d43d8d78bc5f/boredape1.jpeg"
}
{
"image": "https://www.highsnobiety.com/static-assets/thumbor/j2w6qxCWe_zs_suVSTfHEB_nCNo=/1600x1067/www.highsnobiety.com/static-assets/wp-content/uploads/2021/11/02170527/cryptopunk-nft-500-million-2.jpg"
}
{
"attributes": [
{
"trait_type": "Breed",
"value": "Maltipoo"
},
{
"trait_type": "Eye color",
"value": "Mocha"
}
{
"attributes": [
{
"trait_type": "Breed",
"value": "Maltipoo"
},
{
"trait_type": "Eye color",
"value": "Mocha"
}
const buttonTypeKeys = propertiesOf<typeof MyEnum>();
const stringProperties = propertiesOf<string>();
const promiseProperties = propertiesOf<Promise<unknown>>();
// This will list all the readonly properties of MyInterface
const readonlyProperties = propertiesOf<MyInterface>({ readonly: true });
// This will list all the optional properties of MyInterface
const optionalProperties = propertiesOf<MyInterface>({ optional: true });
// This will list all the required properties of MyInterface
const requiredProperties = propertiesOf<MyInterface>({ optional: false });
// But feel free to ask for private readonly OR public optional properties
import { propertiesOf } from 'ts-reflection';
// FREEDOM!!!
const payloadKeys = propertiesOf<SomePayload>();
import { valuesOf } from 'ts-reflection';
// OMG SO MUCH BETTER
const buttonTypes: ButtonType[] = valuesOf<ButtonType>();
const enumKey = ButtonType[ButtonType.PRIMARY]
console.log(buttonTypes);
// The output does not look like what we'd expect!
['primary', 'PRIMARY', 'secondary', 'SECONDARY', 'link', 'LINK']