subscribe type error since version 2.x
See original GitHub issueHi,
I upgraded this morning zustand from version 1.0.7
to version 2.1.0
and I have a typescript compilation error.
First I had to change the syntax with the new subscribe
API. Before I has this:
import create from 'zustand';
interface State {
time: number;
setTime: (time: number) => void;
}
export const [useTranscriptTimeSelector, useTranscriptTimeSelectorApi] = create<
State
>(set => ({
setTime: time => set({ time }),
time: 0,
}));
useTranscriptTimeSelectorApi.subscribe(
time => (player.currentTime = time as number),
{
selector: state => state.time,
},
);
Now with the new syntax I have:
import create from 'zustand';
interface State {
time: number;
setTime: (time: number) => void;
}
export const [useTranscriptTimeSelector, useTranscriptTimeSelectorApi] = create<
State
>(set => ({
setTime: time => set({ time }),
time: 0,
}));
useTranscriptTimeSelectorApi.subscribe(
time => player.currentTime = time,
state => state.time,
);
And I have this error message:
error TS7006: Parameter 'time' implicitly has an 'any' type.
time => player.currentTime = time,
~~~~
If I refer to the readme, my syntax is good.
Thank you for your help.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
subscribe type error since version 2.x · Issue #67 - GitHub
Hi, I upgraded this morning zustand from version 1.0.7 to version 2.1.0 and I have a typescript compilation error.
Read more >Subscribe is deprecated: Use an observer instead of an error ...
I was able to get it to go away by click the version of typescript in the bottom right corner of vs code...
Read more >Subscription Manager error - Red Hat Customer Portal
Hi all,. Is anyone else having issues with trying to register systems to redhat at the moment? I can see the tcp connection...
Read more >3 Common Rxjs Pitfalls (and how to avoid them)
These are 3 situations that we can come across while building Angular apps using RxJs. We are going to go over why the...
Read more >Observable - RxJS
Observables are created using new Observable or a creation operator, are subscribed to with an Observer, execute to deliver next / error /...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, I think I see the issue. I should have a fix for this soon.
The new error is not linked to the listener but how I mock the store.