Skip to content

Commit

Permalink
Add deprecated JSDoc comments for the previous middleware signature (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
lfades and ijjk committed Mar 28, 2022
1 parent 6a4c70e commit 5d1f33f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/next/server/web/spec-extension/fetch-event.ts
Expand Up @@ -10,13 +10,22 @@ export class NextFetchEvent extends FetchEvent {
this.sourcePage = params.page
}

// @ts-ignore
/**
* @deprecated The `request` is now the first parameter and the API is now async.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
get request() {
throw new DeprecationError({
page: this.sourcePage,
})
}

/**
* @deprecated Using `respondWith` is no longer needed.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
respondWith() {
throw new DeprecationError({
page: this.sourcePage,
Expand Down

0 comments on commit 5d1f33f

Please sign in to comment.