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

Improve types of ensure-safe-component helper #1367

Merged
merged 3 commits into from
Mar 7, 2023
Merged

Improve types of ensure-safe-component helper #1367

merged 3 commits into from
Mar 7, 2023

Conversation

simonihmig
Copy link
Collaborator

This will improve the Glint type of ensure-safe-component in two ways:

  • when a component class is passed, the return type will not get narrowed down to an (mostly unusable) ComponentLike<unknown>, but to the type of the passed component itself

    For more context see @dfreeman's comment here

  • when a string is passed that has an entry in the @glint/environment-ember-loose template registry, then the registered type will be returned instead of again ComponentLike<unknown>

Fixes typed-ember/glint#518

This has no test coverage here, as we don't have any type testing infrastructure set up. But I tested this locally in a Glint-enabled project using yalc, and both changes seem to work fine!

Would still love a review from either @dfreeman or @chriskrycho to be sure! 🙏

@ef4 ef4 merged commit 816e502 into main Mar 7, 2023
@ef4 ef4 deleted the util-types branch March 7, 2023 14:10
@ef4 ef4 added the enhancement New feature or request label May 11, 2023
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.

ensure-safe-component breaks types
2 participants