Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// @flow
const SIZE = Object.freeze({
LARGE: "large",
MEDIUM: "medium",
SMALL: "small"
type ISize = $Values<typeof SIZE>
// props type for Avatar component
type IProps = {|
size: ISize,
const Avatar = (props: IProps) => (
// ...component details are omitted
// this works
<Avatar size={SIZE.LARGE} />
// this works as well, althouh it's discouraged
<Avatar size="large" />
// this gives an error
<Avatar size="larg" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment