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

Introduce {{helper}} and {{modifier}} helpers #553

Merged
merged 9 commits into from
Apr 14, 2023
Merged

Conversation

dfreeman
Copy link
Member

High Level

The headline here is adding {{helper}} and {{modifier}}, but the bulk of the diff is actually internal changes to improve inference characteristics for those two helpers and the existing {{component}} one.

Note that the types for these helpers are intrinsically super complicated because their runtime behavior is super complicated, and we're unlikely to ever get 100% fidelity. The error messages can also be heinous, but we provide hints where possible, and this change isn't making matters any worse than they already were on that front with {{component}}.

Details

I had a whole novel written up here and accidentally -Red, so... 😭

The abridged version is that this PR adds a new DSL method resolveForBind as a sibling to resolve and resolveOrReturn. In concert with that, it introduces a bind-invokable special form. When we encounter a helper declared to be bind-invokable, we treat its first argument specially and hand it off to resolveForBind, which has two effects:

  • environments no longer need a custom implementation of {{component}} (and now {{helper}} and {{modifier}}) to account for different resolution semantics
  • the actual types for {{component}} (and now {{helper}} and {{modifier}}) can function just in terms of Glint's internal function representation of invokables, not needing to juggle both the translation and the binding semantics

Other Notes

This also adds a WithBoundPositionals utility type as a counterpart to WithBoundArgs, and as part of documenting that I pulled out the Ember-specific "Contextual Components" docs page into a more general "Glint Types" page that describes the user-facing types that @glint/template exposes.

There's some slightly broader reorganization of the docs that I think could be helpful, but I'll tackle that separately from this change.

Closes #412; fixes #410.

@dfreeman dfreeman added the enhancement New feature or request label Apr 13, 2023
@dfreeman dfreeman merged commit 3501e8b into main Apr 14, 2023
4 checks passed
@dfreeman dfreeman deleted the helper-and-modifier branch April 14, 2023 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support helper and modifier helpers
1 participant