extending express request class in Flow

The error says that an argument/param of type express$Request (Member 1) or null (Member 2) was expected, but web$Request was seen.

Unfortunately, Flow does not support extending/overriding flow/lib types:

https://github.com/facebook/flow/issues/396

What I've begun to do is:

  1. flow-typed install [email protected]
  2. Move express_v4.x.x.js from flow-typed/npm/ to flow-typed/ (outside flow-typed/npm/ so it won't be overwritten by future flow-typed installs, and inside flow-typed/ so flow will automatically make declare blah statements global)
  3. Right below the declare class express$Request... (so it's easy to find and so it's above where it's used inside declare module..., I put:

    declare class express$Request extends express$Request { user: any; isAuthenticated(): boolean; session: { loginForwardUrl: ?string; }; }

I do this instead of putting my custom props on the original class so that it's easy to see which props are custom.