javascript - Flow inheritance - class B extends A incompatible with A -


i expect work , not outputting errors in flow:

/* @flow */  class treenode {   root: treenode }  class rootnode extends treenode {}  class othernode extends treenode {    root: rootnode  } 

but instead get: treenode. type incompatible rootnode. tho rootnode extends treenode

what doing wrong?

you can see issue there https://flow.org/try/#0pqkgbaagzgng9gdzcyaovbjgbdazrsafqccbtugotgbnswbvvmmyuoafwc4izkbtuax3ry8baept2vwmfiapdqqb21aixiy69yzhz4waexyaluss1zfktt038gtzqw7djhs0ka

fields , properties invariant default because can both read , write them. need mark field covariant allow subclasses

/* @flow */  class treenode {   +root: treenode }  class rootnode extends treenode {}  class othernode extends treenode {    root: rootnode  } 

demo. further reading better understanding.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -