Skip to content

Instantly share code, notes, and snippets.

@janjakubnanista
Created June 25, 2020 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janjakubnanista/ad68f2ee179c7c929896f2a8041d4c79 to your computer and use it in GitHub Desktop.
Save janjakubnanista/ad68f2ee179c7c929896f2a8041d4c79 to your computer and use it in GitHub Desktop.
// 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
const verySpecificProperties = propertiesOf<MyInterface>(
{ private: true, readonly: true }
{ public: true, optional: true }
);
// Or maybe a combination of required non-public properties
// and protected optional ones? I mean why not
const evenMoreSpecificProperties = propertiesOf<MyInterface>(
{ public: false, optional: false }
{ protected: true, optional: true }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment