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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -