-
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
component helper w/ class constructor returns nullable value #517
Comments
Although the definition here seems right. Is that supposed to get picked up by TS instead of the other? But even then, why is it thinking it can be null? 🤔 |
That's exactly what the signature above the one you linked does 🙂 Just to confirm, |
No, it isn't:
Yeah, makes sense! 🤔 What I am working on is open source, I can push my work and send you a link later, if that helps! |
@dfreeman I have now pushed my work in progress here, if you want to take a look: CrowdStrike/ember-headless-form#14 I silenced the Glint error mentioned above here. The component constructor is assigned here, without being able to be |
@simonihmig I just pulled |
Sorry, I should have provided a more stable reproduction, than just pointing to a PR... Things there have changed quite a bit since raising this issue, so the Glint error reported here IIRC did go away when introducing I just tried to create a stable reproduction based on the earlier commits. Although I was able to reproduce again, I saw that there was a flaw in how I handled my own generic types. And I was able to fix that error by a simple type cast. So it seems you are right that this wasn't a "general all-the-time problem". Still not understanding really where the I could push my current reproduction (without that type fix), but at this point I guess we don't want to waste more time on this? Therefore closing this issue. Sorry for taking your time here! |
No problem at all! Sorry it took me so long to take a look at this that everything had shifted around in the meantime 😄
If you're satisfied with how you've got things working currently, then I'm happy to leave this closed. But if you do run into the issue again elsewhere (or, for anyone else who comes along and finds this issue: if you run into it), I'm happy to reopen this and dive deeper. |
In a component I yield another (private) component with the component helper, like this:
this.FieldComponent
is the class (constructor) of the other yielded component. It should only be used in the yielded form, and will not be exposed in the app re-exports, that's why I don't pass a string (like in(component "path/to/field")
).The signature for the component is (simplified):
Now Glint complains about this:
It seems to me the issue is that it thinks that the return value of the component helper could be null (which is not the case!), while the block params in the signature don't allow this obviously.
Having had a quick look at the type definitions for the component helper, and with my non-hardcore-expert-level TS skills, I still interpret this definition in such a way, that passing a valid component constructor (which I do) could still return
null
orundefined
. Which is not true, right? Wouldn't it be more correct to say that when the component argument is a valid constructor, then the return value is aPartiallyAppliedComponent
, otherwise in case ofnull
orundefined
being passed in returns just that?The text was updated successfully, but these errors were encountered: