-
Notifications
You must be signed in to change notification settings - Fork 56
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
fix(types): allow middleware props to be optional when specified in global config #458
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I’m not sure they can be optional. |
The default config is used regardless in module.ts, so I assume it can be optional? |
Not if the user deactivates them with ‘false’ |
Well, does the default config per route not work with route level configuration? If a person doesn't specify 'false' at a certain route, won't the default configuration for that route be the one with the default values? If not, then there's the question of whether we want to sacrifice dx for global config to ensure proper values at route level config |
The routes are resolved recursively so if at any level the feature is deactivated with Also if the user changes a default value in the global options (or at any route level), all nested route rules (below that route) will inherit this custom value and not the default value. Even if we changed the code to modify this behaviour, wouldn't we end up in a situation where we have inconsistent behaviour across features ? e.g.
|
I mean, the throwError field is already optional and I haven't seen any issues with that in any of the middleware?
Well, it would inherit from the global config but would be overridden by per-route config, wouldn't it? That way if someone changes the default value in global config, per route config would inherit from the global config, rather than the default one. |
The problem only arises with route-level configurations. |
Interesting... how about adding specific type overload for per route config that would require all required props? |
Absolutely, great idea |
I made the route-specific config have all the required props, so now it shouldn't cause any issues. Although the throwError would also be required in that case. Should this one stay optional? |
Hey @GalacticHypernova, looks good here
In addition, throwError can remain optional because the implicit default is assumed to be |
I don't think I have access to rebase the PR unfortunately, is there a way you could do it please?
I accidentally recreated Required through RequiredOptional, forgot the type existed |
Updated it to comply with the RC branch. Anything else you think I should add? |
|
Done, it should now stay optional.
The default is |
Types of changes
Description
Allows to specify multiple properties only partially while keeping the rest in default values
Checklist: