typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
110 stars 51 forks source link

Generic types with `HelperLike` #540

Closed swastik closed 1 year ago

swastik commented 1 year ago

Thanks for your work on this! 😄 I'm trying to type some external addons that provide helpers. For example:

import { HelperLike } from '@glint/template';

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry {
    or: HelperLike<{
      Args: { Positional: [any, any] };
      Return: any;
    }>;
  }
}

The helper can be invoked like this and it returns either of the two arguments (for example):

{{#let (or a b) as |foo|}}
  {{foo}}
{{/let}}

However, this seems like it will return an incorrect type: any. Is there a way to type these correctly? Thanks for any help!