How can I get type of SignalStore When Separating Store Methods into Different File in an Angular Project Using @ngrx/signals #4236
Replies: 3 comments 5 replies
-
This might work for you?
Then:
Or when also using entities:
Then:
|
Beta Was this translation helpful? Give feedback.
-
As I was having the same issue, but @chrisjwalk 's solution didn't work for me in |
Beta Was this translation helpful? Give feedback.
-
You can use Here is also another example: #4272 (comment) |
Beta Was this translation helpful? Give feedback.
-
I'm working on an Angular project utilizing @ngrx/signals for state management. My goal is to organize my store's methods into separate files for better maintainability and readability. Specifically, I want to extract the withMethods_function from the main store definition file to a separate file and ensure proper typing for the store passed to this function.
Here is how my store is currently defined:
I attempted to define the type of the store in the main file and then use it in the separate file where withMethods_function is located:
Main File:
Separate File for Store Methods:
However, I encountered the following error: 'OrganizationsType' refers to a value, but is being used as a type here. Did you mean 'typeof OrganizationsType'?".
Could someone advise on the correct way to type the state parameter in withMethods_function when it's defined in a separate file? I suspect my approach to exporting and importing the store type might be incorrect.
I want to have the same access to store as if it was in one file.
Beta Was this translation helpful? Give feedback.
All reactions