Last active
March 13, 2017 05:29
-
-
Save garbles/686882c6b2199048f61ac6429d738a92 to your computer and use it in GitHub Desktop.
This file contains 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
import {sample, sampleOne, types} from 'babel-plugin-transform-flow-to-gen/api'; | |
import type {Animal, Dog} from './types'; | |
const dogGen = Animal(types.literal('dog')); | |
const anySpeciesGen = Animal(types.string()); | |
const dog = sampleOne(dogGen); | |
console.log(dog); | |
// { "species": "dog", "name": "ahKL9p" } | |
console.log(Dog()); | |
// { "species": "dog", "name": "1c" } |
This file contains 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
export type Animal<T> = { | |
species: T, | |
name: string | |
} | |
export type Dog = Animal<'dog'>; | |
export type AnySpecies = Animal<string>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment