Argument of type '[]' is not assignable to parameter of type 'string | { type: unknown; }'. #2083
-
Code Sandbox: https://codesandbox.io/s/zustand-state-with-url-hash-demo-forked-tsns8s?file=/src/__mocks__/zustand.ts I'm trying to Connect to state with URL following the first example on this page: https://docs.pmnd.rs/zustand/guides/connect-to-state-with-url-hash When I finish it, I get an error in my mocked zustand instance: Argument of type '[]' is not assignable to parameter of type 'string | { type: unknown; }'. We use a slightly different (maybe outdated) version of it and it seems impossible to reconfigure it to support the hash URL state: export const create = <
T extends unknown,
Mos extends [StoreMutatorIdentifier, unknown][] = []
>(
createState: StateCreator<T, [], Mos>
) => {
const store = actualCreate(createState);
const initialState = store.getState();
storeResetFns.add(() => store.setState(initialState, true)); // <-- this line is the one throwing an error
return store;
}; |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
I'm not super familiar with mocking. Hope @dbritto-dev can help on it. |
Beta Was this translation helpful? Give feedback.
-
@tonycassara thanks I'll look into that and fix your demo |
Beta Was this translation helpful? Give feedback.
-
For my specific use case because we use a mocked I'd also prescribe updating the introduction docs to use currying if that's the preferred method, in my case we already had many uses without it. |
Beta Was this translation helpful? Give feedback.
@tonycassara BTW, I updated your codesandbox following the testing guide -> https://docs.pmnd.rs/zustand/guides/testing
Here you go -> https://codesandbox.io/s/zustand-state-with-url-hash-demo-forked-k3y283