-
Notifications
You must be signed in to change notification settings - Fork 26.2k
signal inputs seem to not work with numberAttribute
(generic is needed, or needs inference)
#53969
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
Comments
This is a bit of a gotcha, it currently needs to be input<number, unknown>(300, { transform: numberAttribute }); The reason is that a transform introduces a divergence in the signal's type: it accepts I am not sure if this can be improved upon, as TypeScript currently requires all generic types to be set instead of inferring some of them (microsoft/TypeScript#54047) |
Also, in this particular case, you can opt not to specify any type arguments at all. In that case everything is fully inferred. It's only the partial inference that doesn't work.
|
Thanks Joost for capturing all of this. We did consider this aspect and talked about it a couple of times. We don't see a good way around this, without other more impactful trade-offs. One correction, the type needs to be: delay = input<number, unknown>(300, { transform: numberAttribute }); The first type parameter is actually the We are good, if TS supports partial type inference, the following will work as well. Right now, either need to be explicit, or fully rely on inference (which is safe here): // will works when TS supports partial type inference
delay = input<number>(300, { transform: numberAttribute });
// works right now
delay = input<number, unknown>(300, { transform: numberAttribute });
delay = input(300, { transform: numberAttribute }); |
numberAttribute
numberAttribute
(generic is needed, or needs inference)
I'm going to mark this issue as blocked since the final solution should come from microsoft/TypeScript#54047 Also developers can relatively easily deal with this situation as pointed out by #53969 (comment) |
Same issue with |
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
Throw error:
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-fv1yrc?file=src%2Fmain.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: