Created
December 14, 2016 11:34
-
-
Save gmmorris/332e089412311da9aca77550d413e072 to your computer and use it in GitHub Desktop.
Flow is failing to infer instanceof checks
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
/* @flow */ | |
function Children (children : Iterable<any>) { | |
this.children = Array.from(children) | |
return this | |
} | |
Children.prototype = { | |
toArray () : any[] { | |
return this.children | |
}, | |
get length () : number { | |
return this.children.length | |
}, | |
[Symbol.iterator] () : Iterator<any> { | |
return this.children[Symbol.iterator]() | |
} | |
} | |
const asChildren = (children : Iterable<any> = []) : Children => | |
isChildren(Children) | |
? children | |
: new Children(children) | |
const isChildren = | |
(children : ?any) : boolean => | |
children instanceof Children |
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
/* @flow */ | |
function Children (children : Iterable<any>) { | |
this.children = Array.from(children) | |
return this | |
} | |
Children.prototype = { | |
toArray () : any[] { | |
return this.children | |
}, | |
get length () : number { | |
return this.children.length | |
}, | |
[Symbol.iterator] () : Iterator<any> { | |
return this.children[Symbol.iterator]() | |
} | |
} | |
const asChildren = (children : Iterable<any> = []) : Children => | |
children instanceof Children | |
? children | |
: new Children(children) | |
const isChildren = | |
(children : ?any) : boolean => | |
children instanceof Children |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment