flow
flow copied to clipboard
Non initialize class fields doesn't treats as nullable
Flow version: 0.144.0
Followed code are invalid at the type level, but it successfully typechecks by Flow:
/* @flow */
class Foo { foo : string } //field 'foo' has no initializer but have type 'string'
const my_foo : Foo = new Foo()
const undefined_here : string = my_foo.foo // 'undefined_here' type was declared as 'string'
// but it's value will be 'undefined'
Expected behavior
Static checking time error.
Actual behavior
Successfully passed typechecking, and undefined at the runtime.