I am using flow-typed
, so it has an express
definition. In my code, I have:
isPayloadSignatureValid(req /*: express$Request */ ) {
const rawBodyPayload = Buffer.from(req.rawBody).toString('utf8')
But flow complains, saying:
Cannot get req.rawBody because property rawBody is missing in express$Request [1].
In my interfaces/express.js
, I have:
// @flow
/*::
type express$Request = exports.Request & {
rawBody: string
}
export type { express$Request };
*/
And in my .flowconfig
, I have:
[include]
./interfaces/.*
SO why isn't the extended express$Request
having the rawBody
property?
Thanks
You're not gonna get the type from interfaces/express.js
when you actually use express. You'd need to import it and inject it yourself. Generally in this situation you'd want to just modify the express libdef from flow-typed directly. Also you should avoid using an intersection type here, you should spread the object types (...
).