Skip to content

Instantly share code, notes, and snippets.

@JoeStanton
Last active October 2, 2016 23:15
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 JoeStanton/b240f0e9979f7fd4eb7a91a8d3471984 to your computer and use it in GitHub Desktop.
Save JoeStanton/b240f0e9979f7fd4eb7a91a8d3471984 to your computer and use it in GitHub Desktop.
// 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