-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the issue has not already been raised
Issue
https://fastify.dev/docs/latest/Reference/Decorators/#decoratereplyname-value-dependencies
import { fastify } from 'fastify';
declare module 'fastify' {
interface FastifyRequest {
foo: Readonly<{ bar: number }>;
}
}
const app = fastify({});
// @ts-expect-error
app.decorateRequest('foo', null); <- `null` doens't satisfy type `{bar: number}`
app.addHook('onRequest', async (req, reply) => {
req.foo = { bar: 42 };
});I don't think change type of .foo to ... | null is a good idea, so the only possible solution I can come up with is to use @ts-ignore or @ts-expect-error on line decorateRequest.
caused by #4858
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels