Skip to content

Simplify specifying block params #8

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

Merged
merged 3 commits into from
Jul 25, 2020
Merged

Simplify specifying block params #8

merged 3 commits into from
Jul 25, 2020

Conversation

dfreeman
Copy link
Member

@dfreeman dfreeman commented Jul 25, 2020

This change reworks how block signatures are specified, going from this:

declare const MyComponent: (args: NoNamedArgs) => AcceptsBlocks<{
  default(foo: string, bar: number): BlockResult;
  inverse?(): BlockResult;
}>;

...to this:

declare const MyComponent: (args: NoNamedArgs) => AcceptsBlocks<{
  default: [string, number];
  inverse?: [];
}>;

This eliminates the need for the useless BlockResult dummy type. It may appear to lose useful information in the form of parameter names, but in fact that already disappears as the type is transformed, and it will also be possible in TS 4 to label tuple elements.

It also (unfortunately) includes a refactoring to reorganize built-in template entities like let and each. Ideally I would have landed that separately, but by the time I realized how much of an impact these two changes would have individually they were already tangled up with one another.

Regardless, I think there's likely to be further refactoring of these things in the future, since the items available look fairly different between GlimmrX, Glimmer.js, and Ember.

dfreeman added 2 commits July 25, 2020 13:36
Likely this is a precursor to a larger refactoring to introduce
something along the lines of "environments"
@dfreeman dfreeman force-pushed the block-params-refactor branch from 3f26543 to 6427285 Compare July 25, 2020 11:50
@dfreeman dfreeman merged commit 59bf76c into master Jul 25, 2020
@dfreeman dfreeman deleted the block-params-refactor branch July 25, 2020 12:00
@chriskrycho
Copy link
Member

I appreciate the write up! Still following your work on this even though I haven’t been able to actively contribute.

@dfreeman dfreeman added the breaking A breaking change label Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking A breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants