feat(signals store): infer type from custom feature #4886
Unanswered
EinfachHans
asked this question in
Q&A
Replies: 2 comments 6 replies
-
Can you provide more details and a code example of what you're trying to achieve? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Sure, let's say we have a custom feature like: const initialState = {
someStateProp: 1,
_somePrivateProp: 0
};
export function withMyFeature<_>() {
return signalStoreFeature(
{
props: type<{ requiredProp: Signal<boolean> }>(),
methods: type<{
someRequiredMethod(): string;
_reset(): void;
}>()
},
withState(initialState),
withMethods((store) => ({
someNewMethod() {
// ...
},
reset() {
// ...
}
}))
);
} I would then need to be able to infer the type of this feature that the store "has" when this feature is applied so basically: {
requiredProp: Signal<boolean>;
someStateProp: Signal<number>;
someRequiredMethod(): string;
someNewMethod(): void;
reset(): void;
} When the store feature has non-private props or computed they should be included as well, so just everything that this feature brings to the table. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Which @ngrx/* package(s) are relevant/related to the feature request?
signals
Information
We have a quire complex custom feature which we apply to different stores to be able to gave them everything they need for a specific flow.
I have components / pages which needs a store, that have this feature set. Everything else doesn't matter.
So i need to infer the type of the store feature function, to correctly have this "part" of the final store, to access it's state, props, methods, ...
I can create a PR, but would need assistance!
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions