This broke in Flow v0.29.0. It worked in previous versions.
/* @flow */
function f({a=5}: {a: number|Function}) {
}
$ ./flow29/flow check
test.js:2
2: function f({a=5}: {a: number|Function}) {
^ function type. This type is incompatible with
2: function f({a=5}: {a: number|Function}) {
^ number
test.js:2
2: function f({a=5}: {a: number|Function}) {
^ number. This type is incompatible with
2: function f({a=5}: {a: number|Function}) {
^ function type
Found 2 errors
@samwgoldman This might be because of BecomeT pinning down things after splitting the union?
Confirmed. I'm on this.
@samwgoldman Any update on this?
We've hit this problem today. We've encountered several open issues on this (such as #183, in the last few comments).
Any way to circumvent that problem?
It's not pretty, but you can fall back to what babel compiles to:
const Icon = ({ size }: IconProps) => {
size = size === undefined ? "sm" : size;
@threehams or more es6 way — props: IconProps with later destructuring: const { size = "sm" } = props
Any updates on this ?
Seems like this is still a problem.
Most helpful comment
@samwgoldman Any update on this?