flowtype: $Subtype seems broken for classes -


i think following should fail:

class { a: boolean; } class b extends { b: boolean; }  // works, "proving" b subtype of const a: = new b();  // however, works! should fail. class c { c: boolean; } // c cannot assigned a, it's not subtype type subtypeacceptor<t> = ($subtype<t>) => boolean; const a2: subtypeacceptor<a> = (c: c) => (typeof c === 'object'); 

what gives? non-generic versions of above fail:

type subtypeacceptorofa = ($subtype<a>) => boolean; const a3: subtypeacceptorofa = (c: c) => (typeof c === 'object'); 

is because, in theory, can c & $subtype<a>? above fails exact object types follows well:

const a4: subtypeacceptor<{| a: boolean |}> = (c: {| b: boolean |}) => c.b; 

where think obvious {| b: boolean |} cannot subtype of {| a: boolean |}.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -