-
-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.15.0
Plugin version
3.1.0
Node.js version
16.19.1
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Monterey 12.6.5
Description
Hi,
Just updated plugin to version 3.1.0 recently and it looks like I lost types inference on the fastify routes handler request object. I rollbacked to 3.0.0 which is working fine. The following screenshot is showing that I no longer get types inference on the params
object of the fastify request despite schema definition being provided and Typebox type provider being used.
Thank you for your help ;)
Steps to Reproduce
import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox';
import { Type } from '@sinclair/typebox';
import fastify from 'fastify';
fastify()
.withTypeProvider<TypeBoxTypeProvider>()
.get('/', {
schema: {
params: Type.Object({
foo: Type.String()
})
},
handler(req, rep) {
console.log(req.params.foo);
rep.send();
}
});
Expected Behavior
- In the previous example,
req.params.foo
should be typed as astring
. - Using
strict
flag with typescript, I should not get the following error:
'req.params' is of type 'unknown'.ts(18046)
oshox, seia-soto, acidoxee, limulus and ashervb
Metadata
Metadata
Assignees
Labels
No labels