Introduce template primitives for modifiers and attrs #70
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.
Overview
This PR introduces template primitives for enforcing some degree of type safety with attributes and modifiers. It retires
invokeModifier
and introduces three new primitives:It also introduces
ElementForTagName
andElementForComponent
utility types that take a tag name or an invokable constructor respectively and give an appropriateElement
subtype, ornull
in the case of a component with no root element.Finally, it adds an
Element
field to component signatures and propagates that information to be available both for invoking them and in their template context (𝚪
) in order to ensure that:...attributes
within a template is legal (i.e. the target element is equivalent to or a subtype of the component's declareElement
)Examples
Attributes
Splattributes
Modifiers
Notes
This is a breaking change, so I'll probably aim to cut a
v0.4.0
release in the near future, depending on the timing of the announcement blog post. If possible I'm also hoping to land some internal cleanup (rationalizing module layout, fixing up some type names, that sort of thing) soon, but that won't block release if we're ready to go sooner.Closes #21.