-
Notifications
You must be signed in to change notification settings - Fork 6
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
Optionize3 should allow some defaults from the first arg #118
Comments
Perhaps https://stackoverflow.com/questions/66426230/how-to-enforce-a-type-for-multiple-arguments-in-typescript will be helpful. We can look at the type of both arguments to determine that together they include all defaults. @samreid, do you think this is possible? |
If this was possible, it would be a game changer, and basically fix the issues with how type SelfOptions = {
foo?: number;
bar?: boolean;
other?: string;
}
const options = optionize5<ProvidedOptions, SelfOptions>()( { foo: 5 }, { bar: true }, { other: 'hi' }, {}, providedOptions ); |
It seems we need a type that says But that doesn't flag excess properties: const options = optionize<FocalLengthControlOptions, SelfOptions, NumberControlOptions>()( {
bar: 6,
...numberControlDefaults,
test: 'fake'
}, providedOptions ); Want to add this to one of our Tuesday agendas? |
This will be quite a bit of work to investigate. It should be handled as part of our next optionize sprint. |
@pixelzoom and I were talking over in phetsims/utterance-queue#81 (comment) (in a zoom call), and it would be so very nice if we could have this code working in FocalLengthControl:
@samreid, it actually doesn't seem like too much of an issue to
&
the first two args to gether to make the defaults happen. If that occurs inside of Optionize, then we are in luck and won't need too many duplicate lines calling optionize.The text was updated successfully, but these errors were encountered: