Add simpler way to use Component#27664
Conversation
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (300 lines, 6 files), I've queued these reviewers:
How this works
|
| allComponents: readonly Factory<TComponent, TConfig>[], | ||
| lazyConfiguration: (composed: ComposedComponents<TComponent, TConfig>) => TConfig = ( | ||
| composed, | ||
| ) => composed as unknown as TConfig, |
There was a problem hiding this comment.
I generally don't like overloads as they add this kind of non-type safe stuff.
In this case the other option is two differently named functions (since generic inference won't let you get away with one generic function for this)
I'm thinking maybe simply "compose" and "composeCustom". These seem fine especially given the functions are nested in a namespace already, which avoids the issue of having a top level too generic sounding compose, and makes the "custom" one not have too long of a name.
Thoughts on which is better?
There was a problem hiding this comment.
I personally like the user-experience of overloads for discoverability, but I agree that in this case (especially with the proposed naming) it matters less since intellisense will surface both options for autocomplete and such.
So, I guess I have a slight preference for the overloads, given that we only need the one type-cast, but I'd be fine with either.
There was a problem hiding this comment.
Kept the overload, but did the renames to the shorter name.
|
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output |
Bundle size comparisonBase commit: The PR's CI build failed — fix the build and the comment will update once the next run succeeds. |
Description
Add overload and default parameters to easy simple case use of Component API
Reviewer Guidance
The review process is outlined on this wiki page.