I have a State:
type MyState = {
elements: ElementDTO[] | undefined,
};
And a NGRX - Signal Store:
export const ElementStore = signalStore(
{providedIn: "root"},
withState<ElementState>(initialState),
.
.
withMethods((store) => ({
.
.
pushElement(element: ElementDTO): void {
patchState(store, {
elements: [...store.elements(), element]
});
}
})
),
)
But i get the error:
error TS2488: Type 'ElementDTO[] | undefined' must have a 'Symbol.iterator' method that returns an iterator.
What is wrong here?
After hours of trying, this seems to work
The strange thing is that IntelliJ still shows an error on this line. However, the app compiles and seems to run. The syntax of ngrx seems to be straight from hell!