Need to type a function using $Subtype and generics

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Need to type a function using $Subtype and generics



I’m trying to use $Subtype to type a mixin function. I believe my type signature is correct. I keep getting some errors:


$Subtype


const MyMixin: MixinFunction = superclass => class extends superclass ;
^ Cannot extend `superclass` [1] with
`<<anonymous class>>` because `A` [2] is
not inheritable.



Here is my super simple code (on Try Flow):


type MixinFunction = <A>(superclass: Class<A>) => Class<$Subtype<A>>;

const MyMixin: MixinFunction = superclass => class extends superclass ;



How can I made this code work without errors?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard