-
Notifications
You must be signed in to change notification settings - Fork 92
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
signal-based inputs and componentInputs type #464
Comments
@xfh sorry for my late response. Feel free to open a PR for this. |
I initially ran into this because I was using This is because of I wonder what type errors OP was running into. |
Hi, sorry for the late replay - I'm on holidays. @andreialecu, I typically use a setup function for my component tests, where I used to type the inputs as In my opinion, I'd be good to provide better types for componentInputs and remove the type union. That would be a breaking change though. I am assuming, that the type union was introduced to support input with an alias? We could provide another api to support aliases. What do you think @timdeschryver ? |
I'd like to add that the union with One fix would be to deprecate the property and create a brand new one which allows aliases via some branded type. For example:
Where Then it's not necessarily a breaking change, the old property will continue to work as is. |
I opened a PR at #473 with my proposal. Consider it a draft for now. |
Hi
I started migrating some components to signal based
input
andmodel
functions. Unfortunately, that causes typing issues.RenderComponentOptions declares
componentInputs?: Partial<ComponentType> | { [alias: string]: unknown };
, which resolves the types as InputSignal or similar.Would you accept a helper type to unwrap the value of signals?
I think this should do the trick:
This doesn't help much when using the render function directly, because of the type union for the aliases. But when using a setup function we can declare an input property without the aliases and benefit from better type support. E.g.
Obviously, I can do all this without a change in angular-testing-library. I just thought it might become a common issue with growing adoption of signal inputs and wanted to share my workaround.
The text was updated successfully, but these errors were encountered: