-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declaration Merging over scopes in the documentation #3529
Comments
@fastify/typescript do you know if it's possible to use declaration-merging over scopes by just a configuration in the tsconfig? Looks like a barrier. |
It would be interesting to understand how declaration merging actually works here. Please correct me if I'm wrong but I believe that the If that is true, then the problem becomes: how do we restrict declaration merging in a way that it only applies to certain parts of the codebase? It sounds like a tricky problem to solve! |
If anyone tackles this before #3474 is merged, please branch from it and target that branch in the PR. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I gave it a shot 5 months ago, however, I haven't found a good way to do that. @fastify/typescript @sinclairzx81 do you have any thoughts on that? Otherwise, I'll close it. |
@RafaelGSS Hi Unfortunately, I don't see a easy way to enable this without changing the signature of // remap to Fastify<DefaaultFastifyContext & { jwt: {...} }>
fastify.register((fastify, opts) => { return { jwt: require('fastify-jwt') } })
.register(async (fastify, opts) => { console.log(fastify.jwt); return {} }) One thought might be to drop the In terms of the It might be best to defer this for a later time (I think there could be a larger discussion to be had around aligning some of the JS logic to be a bit more conducive towards TS inference) and narrowing some of the ways users can interact with Fastify, this with some notes to other issues I've seen such as #3810 (comment). Hope that helps! |
Thank you! |
Prerequisites
馃殌 Feature Proposal
In the documentation, we have some sections approaching the
declaration merging
, however, looks reasonable to add a declaration merging over scopes as well.For instance, you have scope X and scope Y:
Motivation
Fastify was designed to work gracefully with encapsulation, and it should be replicated by their types.
The text was updated successfully, but these errors were encountered: