-
Notifications
You must be signed in to change notification settings - Fork 51
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
ensure-safe-component breaks types #518
Comments
I think there are a few things going on here, all of which are interplaying to lead to this error:
Finally, there's something subtle (and, I think, not directly Glint-related) going on with your The reason for that is that you have two unique |
Hi Dan, sorry for taking so long to get back to this, finally I have incorporated your feedback into CrowdStrike/ember-headless-form#57. So thanks for that, I think you pretty much nailed everything! In order of your points:
One note though about 3.: I think due to With generic functions or classes, TS would be able to infer what |
Are you sure? Did you check? 🙂 |
I did not. 🙈 I will file a PR with the changes to |
In a project I have Glint types working, where I pass a component constructor to
{{component}}
, which matches the expectedWithBoundArgs
defined for the block params, like this:Again, working fine! (Reproducible state in this commit)
Then, for Embroider compatibility, I am wrapping the component constructor with
(ensure-safe-component)
:I copied its type definition from its own source (which @chriskrycho added, but which are not released yet unfortunately). Its type definition looks good AFAICT, trying to preserve the signature of a passed component constructor.
However starting from here (in this commit, I am getting weird type errors, like
Argument of type 'typeof HeadlessFormFieldComponent' is not assignable to parameter of type 'string | ComponentLike<unknown>'.
(unknown
!?) andType 'void | DebuggerKeyword | HasBlockKeyword | HasBlockParamsKeyword | InElementKeyword | LetKeyword | ... 20 more ... | typeof HeadlessFormComponent' is not assignable to type 'InvokableConstructor<...>
(which probably is a transitive error from the first?)Full details
Full CI log here
Interestingly I was able to fix this by casting the assignment of the component constructor (in the backing class) to an explicit
ComponentLike<...>
(in this commit).Seems there are nitty gritty differences between
ComponentLike<MyComponentSignature>
andtypeof MyComponent
, that come into play here, right? Is that expected?The text was updated successfully, but these errors were encountered: