Skip to content

Commit 5d1f33f

Browse files
lfadesijjk
andauthored
Add deprecated JSDoc comments for the previous middleware signature (#35448)
Something I noticed while using Middleware is that the older and no longer working methods are still accessible for the `event` with autocompletion because of their types, and the way of knowing they're deprecated is by running the app and seeing the error message, this should improve that when coding in tools like VS Code. ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [x] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
1 parent 6a4c70e commit 5d1f33f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/next/server/web/spec-extension/fetch-event.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@ export class NextFetchEvent extends FetchEvent {
1010
this.sourcePage = params.page
1111
}
1212

13-
// @ts-ignore
13+
/**
14+
* @deprecated The `request` is now the first parameter and the API is now async.
15+
*
16+
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
17+
*/
1418
get request() {
1519
throw new DeprecationError({
1620
page: this.sourcePage,
1721
})
1822
}
1923

24+
/**
25+
* @deprecated Using `respondWith` is no longer needed.
26+
*
27+
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
28+
*/
2029
respondWith() {
2130
throw new DeprecationError({
2231
page: this.sourcePage,

0 commit comments

Comments
 (0)