You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which @angular/* package(s) are relevant/related to the feature request?
@angular/core
Description
inputs signals are supposed to be readonly. but if the input is an object (like an options object), that readonly guarantee isn't pass down to the child properties.
myInput = input<{
childProperty: string
}>();
ngOnInit(){
myInput.set({childProperty: 'hello'}); // this isn't allowed...
myInput().childProperty = 'hello'; // but this is allowed!
}
I don't understand why this is the default. surely the assumption should be that transforming child properties against an input signal object value isn't desirable as it bypasses change detection.
In other words, I don't think that I should have to do this every time:
myInput = input<Readonly<{
childProperty: string
}>>();
ngOnInit(){
myInput().childProperty = 'hello' // this is not allowed anymore
}
Proposed solution
Ensure that child properties on input signal object values are readonly, to be consistent with the signal itself being readonly.
Alternatives considered
Using typescript's built-in Readonly type to wrap the signal's generic each time (which is a footgun because you have to remember to do it)