Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for type of route handler returned value at build time (via the…
… TS plugin) and at runtime (#51394) ### What? Fixes #51130. Before this PR, the package assumes that route handlers return a `Response` which is not necessarily the case. The linked issue specified three suggestions to resolve this 1. Return a default 200 response 2. Throw a better error message 3. or both ~~In this issue I implemented (3), except that it is a warning and not an error. Do tell if the team wants to follow a different approach, as it is not too hard to change this.~~ This PR implements (2). ### How? The returned value of the handler is checked at runtime to ensure it is actually a `Response` instance. The return type `AppRouteHandlerFn` is also modified to `unknown` to avoid similar assumptions elsewhere. The TS plugin is also modified to check for the return type during build time. Co-authored-by: JJ Kasper <[email protected]>
- Loading branch information