question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

subscribe type error since version 2.x

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremyRHcommented, Oct 24, 2019

Thanks, I think I see the issue. I should have a fix for this soon.

0reactions
lunikacommented, Oct 30, 2019

The new error is not linked to the listener but how I mock the store.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found