Skip to content

Conversation

@danieljust
Copy link

This PR adds Glint support for element helper, so consumers will be able to

import type EmberElementHelperRegistry from 'ember-element-helper/template-registry';

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry extends EmberElementHelperRegistry { }
}

and {{element}} won't throw errors in hbs templates.

README.md Outdated

```ts
import '@glint/environment-ember-loose';
import type EmberElementHelperRegistry from 'ember-css-modules/template-registry';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import type EmberElementHelperRegistry from 'ember-css-modules/template-registry';
import type EmberElementHelperRegistry from 'ember-element-helper/template-registry';

package.json Outdated
"concurrently": "^7.2.2"
},
"peerDependencies": {
"@glint/template": "1.0.0-beta.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@glint/template": "1.0.0-beta.3"
"@glint/template": "^1.0.0-beta.3"

@@ -0,0 +1,11 @@
import Helper from '@ember/component/helper';
import type { ComponentReturn } from '@glint/template/-private/integration';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on private types for this is (a) dangerous, but (b) fortunately unnecessary 🙂

You can do this with public API and actually get the correct typing for it as well by defining the signature as something like:

export interface ElementHelperSignature<T extends string> {
  Args: {
    Positional: [name: T];
  };
  Return: ComponentLike<{
    Element: 
      T extends keyof HTMLElementTagNameMap
        ? HTMLElementTagNameMap[T]
        : Element;
    Blocks: { default: [] };
  }>;
}

export default class ElementHelper<T extends string> extends Helper<ElementHelperSignature<T>> {}

@NullVoxPopuli
Copy link
Collaborator

@danieljust thank you so much for your work! it was pulled in to #107 and we got it merged -- than kyou!!

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.

4 participants