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

Add TS type definition for hbs import #18

Closed
wants to merge 1 commit into from

Conversation

josemarluedke
Copy link

Adds simple type definition for the hbs import import { hbs } from 'ember-template-imports';.

Helps with #14.

Copy link
Collaborator

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

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

👍🏼 to this as a good stopgap here.

@chriskrycho chriskrycho added the enhancement New feature or request label May 18, 2022
Comment on lines +1 to +3
interface TemplateFactory {}
export function hbs(template: string): TemplateFactory;
export function hbs(tagged: TemplateStringsArray): TemplateFactory;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm. The TemplateFactory definition here won't actually do anything; it's just an empty interface. We need to do one of:

  • importing the actual type from Ember's types and using that so we can guarantee interop (recommended)
  • making it return unknown, which will require casts for folks to use it (not recommended)

@chriskrycho
Copy link
Collaborator

As we start to move toward stabilizing <template>, I'm doing some cleanup—I welcome input from @dfreeman and @jamescdavis here on the TS front, and from other folks on Framework on the more general front:

My very strong intuition here is that we should not ship a specific type for this hbs, and indeed move to deprecate it.

@dfreeman
Copy link
Collaborator

If you're using Glint with ember-template-imports today, I believe we provide a declaration for hbs there (and if you're not using Glint, you're going to get a bunch of spurious "unused symbol" errors from vanilla TS).

As we move toward our next breaking release of Glint, though, I'm inclined to agree with @chriskrycho and say we should probably drop that and discourage the use of hbs since <template> has been officially adopted as the path forward.

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.

3 participants