Last active
October 2, 2016 23:15
-
-
Save JoeStanton/b240f0e9979f7fd4eb7a91a8d3471984 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type Definitions | |
type UserListing = { | |
users: Array<User> | |
} | |
type ProfilePic = { | |
url: string, | |
width: number, | |
height: number | |
} | |
type Role = "Administrator" | "Editor" | "Reader"; | |
type Administrator = "Administrator"; | |
type User = { | |
id: number, | |
firstName: string, | |
lastName: string, | |
role: Role, | |
activated: bool, | |
profilePic: ProfilePic | |
} | |
// Usage | |
import {UserListing} from "./types"; | |
import {gen, genN} from "flow-runtime"; | |
gen(UserListing); | |
// Output | |
{ | |
"users": [ | |
{ | |
"id": 1, | |
"firstName": "String", | |
"lastName": "String", | |
"role": "Administrator", | |
"activated": true, | |
"profilePic": { | |
"url": "String", | |
"width": 1, | |
"height": 1 | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment