Open Syammed2429 opened 4 months ago
@JoaoPauloLousada
you should be able to import it from the lib.|
import { ZustandBaseService } from 'ngx-zustand';
How can I use the persist store for this I tried but I end up with lots of an errors, could you please help me @JoaoPauloLousada
import { Injectable } from '@angular/core';
import { ZustandBaseService } from 'ngx-zustand';
interface CounterState {
counter: number;
increment: () => void;
decrement: () => void;
}
@Injectable({
providedIn: 'root',
})
export class CounterService extends ZustandBaseService<CounterState> {
initStore() {
return set => ({
counter: 0,
increment: () => set(state => ({ counter: state.counter + 1 })),
decrement: () => set(state => ({ counter: state.counter - 1 })),
});
}
}
some errors
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:53 - error TS1005: '>' expected.
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:58 - error TS1005: ',' expected.
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:60 - error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~~~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:63 - error TS1005: ';' expected.
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:64 - error TS1128: Declaration or statement expected.
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:66 - error TS2348: Value of type 'typeof Observable' is not callable. Did you mean to include 'new'?
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~~~~~~~~~~~~~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:77 - error TS2304: Cannot find name 'S'.
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:13:79 - error TS1005: '(' expected.
13 useStore<S>(selector: Parameters<typeof useStore<T, S>>[1]): Observable<S>;
~
Error: node_modules/ngx-zustand/lib/zustand-base.service.d.ts:14:1 - error TS1128: Declaration or statement expected.
14 }
@JoaoPauloLousada
This seems to be a TypeScript issue @Syammed2429 - check your compiler version and check if it's up to date.
If it is, it's likely the lib's TS version is not compatible with yours (libraries last update was ~18 months ago?), in that case you'd need to modify your tsconfig.json
to be less strict
Seems duplicate of #10
@Marcial1234 please feel free to contribute to the project :) Adding backwards compatibility with old typescript and angular versions would be awesome.
I did something like that , but it's throwing an error like
Cannot find name 'ZustandBaseService'.ts(2304)
so from where I can import it??