question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Express's `Middleware` type is not correct

See original GitHub issue
  declare type Middleware =
    ((req: Request, res: Response, next: NextFunction) => mixed)|
    ((error: ?Error, req : Request, res: Response, next: NextFunction) => mixed);

https://github.com/flowtype/flow-typed/blob/master/definitions/npm/express_v4.x.x/flow_v0.25.x-/express_v4.x.x.js#L90

I don’t know how flow handle union type of function. But according to the doc and variance rule, Middleware should be an intersection type, not union type.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
richardscarrottcommented, Nov 12, 2016

@vkurchatkin Is there no way for flow to determine the types based on arity?

0reactions
pascalduezcommented, Aug 16, 2019

Is this issue still happening with the very latest version of the definition?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express Typescript use the correct types for error middleware
Trying to get my types correct in express. I have the following middleware error function. I cannot seem to get the types correct...
Read more >
Using middleware - Express.js
An Express application can use the following types of middleware: Application-level middleware; Router-level middleware; Error-handling middleware; Built-in ...
Read more >
Express plugin does not work correctly when automatic ...
When disabling automatic loading of all plugins and enabling only the express one, full traces (express.request and express.middleware ...
Read more >
Complete Guide to Express Middleware - Reflectoring
If the value of the content-type header does not match application/json , we are sending back an error response with status 400 accompanied...
Read more >
How To Use And Write Express Middleware
This middleware now checks to see if the query parameter admin=true is in the URL and if it is not an error message...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found