-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Spectator is forcing to add a transform explicitly if input() has got a transform function #649
Comments
@kfrancois what do you think? |
Good catch! Internally, export declare interface InputSignal<ReadT> extends InputSignalWithTransform<ReadT, ReadT> {
} Meaning that it extends There is one point where I think some feedback is necessary:
Let's say we have the following component: class MyComponent {
disabled = input(false, { transform: booleanAttribute });
} As If we decide to infer export type InferInputSignal<T> = T extends InputSignalWithTransform<any, infer K> ? K : T;
export type InferInputSignals<C> = {
[P in keyof C]+?: InferInputSignal<C[P]>;
};
// { disabled?: unknown }
type MyInputs = InferInputSignals<SidebarPanelEntryComponent>; If we decide to infer export type InferInputSignal<T> = T extends InputSignalWithTransform<infer K, any> ? K : T;
export type InferInputSignals<C> = {
[P in keyof C]+?: InferInputSignal<C[P]>;
};
// { disabled?: boolean }
type MyInputs = InferInputSignals<SidebarPanelEntryComponent>; On one hand, it's a much nicer dev experience to have the internal On the other hand, this makes it harder to test input transforms. Something like My personal thoughts are: I considered the option to infer both |
To be honest I'm really busy these days and I don't have time for this :) I trust you to reach a solution and open a PR. Thanks |
Disclaimer: I am not an expert with angular testing :) But adding my thoughts ... I think the solution should be kept to what So, if |
Let's say I have a
XyzComponent
. I have to passid
in route-params toXyzComponent
.Inside
XyzComponent
:id = input(undefined, { transform: numberAttribute });
Inside
xyz.component.spec.ts
fileas you can see we have to explicitly add { transform: numberAttribute } because the ngneat/spectator v17 doesn't infer transformFn.
Solution that we came up with:
all we did was to add
infer _
in InferInputSignal. And we are overridingSpectatorOverrides
withCustomSpectatorOverrides
, with this we are able to achieve:this might be a workaround. can you please fix this in appropriate way?
The text was updated successfully, but these errors were encountered: