Skip to content
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

Optionize example for nested options #8

Open
jessegreenberg opened this issue Sep 13, 2024 · 0 comments
Open

Optionize example for nested options #8

jessegreenberg opened this issue Sep 13, 2024 · 0 comments
Assignees

Comments

@jessegreenberg
Copy link
Contributor

Over slack I asked

In WilderOptionsPatterns.ts, why do this? (Why use combineOptions)

    // Feel free to name "initial" to house the type returned from optionize
    const initialOptions = optionize<CoffeeCupOptions, StrictOmit<CoffeeCupOptions, 'handleOptions' | 'isABigCup'>>()( {
      percentFilled: 30
    }, providedOptions );

    // combineOptions can be helpful when providing defaults to nestedOptions.
    initialOptions.handleOptions = combineOptions<HandleOptions>( {
      length: 4 // CoffeeCups have larger handles
    }, initialOptions.handleOptions );

Instead of this?

   // Feel free to name "initial" to house the type returned from optionize
    const initialOptions = optionize<CoffeeCupOptions, StrictOmit<CoffeeCupOptions, 'isABigCup'>>()( {
      percentFilled: 30,
      handleOptions: {
        length: 4
      }
    }, providedOptions );

@zepumph mentioned that this seems buggy and that another optionize call might be better. But I was also wondering why that is necessary, what does the second optionize/combineOptions call for nested options offer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants