Skip to content

Non initialize class fields doesn't treats as nullable #8588

Open

Description

@Renegatto

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.

Reproducing:

at the flow.org/try

Activity

  1. added
    Typing: soundness
    and removed on Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Typing: soundnessbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions