Skip to content

Instantly share code, notes, and snippets.

@leonardfactory
Last active September 2, 2016 11:13
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 leonardfactory/f2d90114e39befcb80324fb8813fed19 to your computer and use it in GitHub Desktop.
Save leonardfactory/f2d90114e39befcb80324fb8813fed19 to your computer and use it in GitHub Desktop.
Data types in Flow
// Definition
export type Primitive = { type: string; };
// 'Factory'
export function Primitive(type:string) {
return {
type: string;
}
}
// Flow throws error since `Primitive` is a duplicated declaration.
// Which is the 'nice way' in order to declare factories & data type definitions?
// I'd like to avoid something like `function primitive()` since the cap specifies
// it's a Data type factory and not just a common function, but I don't know if this is correct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment