Get {{component}}
working more robustly
#20
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change very nearly gets the types for
{{component}}
working correctly.For components with no type parameters, everything should work as expected. Any number of named args may be pre-bound, and they become optional when invoking the resulting component value.
For components with type parameters, if arguments not involved with the type parameters (or none at all) are pre-bound, any type params on the constructor are preserved in the resulting component value.
In other words,
{{component AnimatedEach use=this.transition}}
will result in a value with a signature like<T>(args: { items: Array<T> }) => AcceptsBlocks<{ default: [T, number] }>
, so the type of items passed in will be reflected in the yielded block parameter.The one place that requires care is if you wish to pre-bind an arg that fixes a type parameter on the component in question. To accomplish that, the type parameter itself needs to be fixed outside of template space, i.e.
This also ignores positional parameters, but to be honest I'm not actually 100% sure what the semantics for partial application are there anyway, and they're not supported by Glimmer components or by angle bracket invocation, so that feels like an ok loss.