rsnext/test/e2e/app-dir/app-routes
Vũ Văn Dũng f47c409174
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 <22380829+ijjk@users.noreply.github.com>
2023-09-08 03:26:53 +00:00
..
app Check for type of route handler returned value at build time (via the TS plugin) and at runtime (#51394) 2023-09-08 03:26:53 +00:00
handlers Ensure WebSocket is polyfilled for node runtime as well (#48924) 2023-04-28 15:48:14 -05:00
app-custom-route-base-path.test.ts Support basePath with edge runtime for Custom App Routes (#52910) 2023-07-19 23:54:34 +00:00
app-custom-routes.test.ts Check for type of route handler returned value at build time (via the TS plugin) and at runtime (#51394) 2023-09-08 03:26:53 +00:00
helpers.ts type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
next.config.js Support basePath with edge runtime for Custom App Routes (#52910) 2023-07-19 23:54:34 +00:00