I'm trying to extend a Flow Type that I am importing from an external library like so:
import type { $Request, $Response } from 'express';
export type Req extends $Request {
  additionalField: {
    key: string
  }
};
This won't work, but I'm wondering if there is another way to accomplish this in Flow. I need a new type that inherits a previous type and has a few more properties on top of that.
You might consider the Intersection type, which is created using the & operator. 
The following should work:
type Req = $Request & {
  additionalField: {
    key: string
  }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With