types: restrict route lookup methods (#6963)
#### Description `hasRoute` and `findRoute` look up a route for a single HTTP method, but their TypeScript definitions reused `RouteOptions.method`, which also allows method arrays for route registration. Both APIs forward one method to the router after normalizing it with `toUpperCase()`. Arrays are only meaningful during route registration; for a lookup they have no defined result semantics and currently cause a runtime `TypeError`. This narrows the `method` option for both lookup APIs to `HTTPMethods` and adds type tests to reject method arrays. #### Checklist - [ ] run `npm run test && npm run benchmark --if-present` - [x] tests and/or benchmarks are included - [ ] documentation is changed or added - [x] commit message and code follows the [Developer's Certificate of Origin](https://github.com/fastify/.github/blob/main/CONTRIBUTING.md#developers-certificate-of-origin-11) and the [Code of conduct](https://github.com/fastify/.github/blob/main/CODE_OF_CONDUCT.md) Signed-off-by: haoxiang Yan <108142374+Yanhaoxi@users.noreply.github.com>
H
haoxiang Yan committed
dfd9dc0b9becb0cd2090da2a4d9f978fa5482857
Parent: 4a3e325
Committed by GitHub <noreply@github.com>
on 9/23/2026, 6:09:12 PM