In comparison with TypeScript, Flow doesn't catch these errors:
let n = 0
let s = "S"
test(n) // ok
// TypeScript only errors:
test(s)
n += s
let s2 = String()
let n2 = n // inherit type Number
test(n2) // ok
// TypeScript only errors:
test(s2)
n2 += s2
function test(n = 0) {}
Why? Is it ideology-based decision?
Since you didn't specifically annotate the test function, flow bases its inference off of the types with which you call it. Flow infers your test function to have the type:
(n?: number | string) => void
This probably can be closed.
/cc @vkurchatkin
Type inference not working: We can close this :laughing:
Most helpful comment
Since you didn't specifically annotate the test function, flow bases its inference off of the types with which you call it. Flow infers your test function to have the type: