-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No module augmentation #471
base: main
Are you sure you want to change the base?
Conversation
expectType<FastifyPluginAsync<FastifyStaticOptions, Server>>( | ||
fastifyStaticStar.fastifyStatic | ||
) | ||
app.register(fastifyStatic, { root: '/' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I properly understand the change, we now require an object to be always passed when we register a fastify plugin (so it's no longer optional). This is a breaking change, we should really careful if we want to ship it as it is, since it will break existing TS codebases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An object is not necessary, fastify static plugin has a mandatory root param. Removing the object leads to
Overload 1 of 3, (plugin: FastifyPluginCallback<FastifyPluginOptions, BaseFastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault, FastifyDecorators>>, opts?: FastifyRegisterOptions<...> | undefined): BaseFastifyInstance<...> & ... 1 more ... & { ...; }, gave the following error.
Argument of type FastifyStaticPlugin<BaseFastifyInstance<any, any, any, any, any, FastifyDecorators>> is not assignable to parameter of type FastifyPluginCallback<FastifyPluginOptions, BaseFastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault, FastifyDecorators>>.
Types of parameters opts and opts are incompatible.
Property root is missing in type FastifyPluginOptions but required in type FastifyStaticOptions.
...
Making root optional fixes the error.
If anything, the possibility of not providing root was a bug as far as i can tell.
@@ -129,20 +138,24 @@ const appWithHttp2 = fastify({ http2: true }) | |||
|
|||
appWithHttp2 | |||
.register(fastifyStatic, options) | |||
.after(() => { | |||
appWithHttp2.get('/', (request, reply) => { | |||
.after((err, instance) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see which test case this is, the code is obscured with the error message. Can you provide a test case that i can take a look at?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It refers to the test case on line 140
.
Basically, with the change, this test should still pass
WIP #5093
Checklist
npm run test
andnpm run benchmark
and the Code of conduct