Describe the feature or problem you'd like to solve
When using MockRender(Component) the params take input signals as-is, which breaks usage.
Example:
@Component()
export class MyComponent {
myInput = input<string>(null);
}
const params = MockRender(MyComponent).componentInstance;
// p has type `{myInput: InputSignal<string>}`
The sensible type would be:
const params = MockRender(MyComponent).componentInstance;
// p has type `{myInput: string | undefined}`
Proposed solution
DefaultRenderComponent could be extended like this:
import type { InputSignalWithTransform } from '@angular/core';
type InputBindingType<T> =
T extends InputSignalWithTransform<any, infer WriteT>
? WriteT
: T;
export type DefaultRenderComponent<MComponent> = {
[K in keyof MComponent]: InputBindingType<MComponent[K]>;
};
Breaking Change
Of course, technically, this would be a breaking change, but I think this is what every user would expect anyways. Also the old type (probably) did not really work, as assigning an singal instance to a signal input does not make sense.
Additional context
Relevant docs:
When MockRender(Component) is used without params then fixture.componentInstance controls @inputs and @outputs of the component. That lets it trigger the correct lifecycle hooks.
This then could be updated to
When MockRender(Component) is used without params then fixture.componentInstance controls @inputs and @outputs of the component. That lets it trigger the correct lifecycle hooks. For signal inputs it automatically uses the binding/write type.
Describe the feature or problem you'd like to solve
When using
MockRender(Component)the params take input signals as-is, which breaks usage.Example:
The sensible type would be:
Proposed solution
DefaultRenderComponentcould be extended like this:Breaking Change
Of course, technically, this would be a breaking change, but I think this is what every user would expect anyways. Also the old type (probably) did not really work, as assigning an singal instance to a signal input does not make sense.
Additional context
Relevant docs:
This then could be updated to