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.

MyStore does not satisfy the constraint 'Record<string | number | symbol, unknown>'.

See original GitHub issue

The following code runs fine on 3.0.0:

import create from 'zustand';

type PlayState = 'playing' | 'paused' | 'stopped';

export interface PlayerStore {
  playState: PlayState;
  showOutline: boolean;
  setPlayState: (state: PlayState) => void;
}

export const usePlayerStore = create<PlayerStore>((set) => ({
  playState: 'paused',
  showOutline: false,
  setPlayState: (playState) => set(() => ({ playState })),
}));

But breaks on 3.1.0, with the following error message, by tsc:

PlayerStore does not satisfy the constraint 'Record<string | number | symbol, unknown>'.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dai-shicommented, Sep 8, 2020

OK, here’s the fix using interface. https://codesandbox.io/s/wonderful-bohr-7oqxn

export interface PlayerStore extends State {
  playState: PlayState;
  showOutline: boolean;
  setPlayState: (state: PlayState) => void;
}

Is it acceptable for your use case?

1reaction
dutzicommented, Sep 8, 2020

Sure, it’s not a lot to change 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

MyStore does not satisfy the constraint 'Record<string | number
The following code runs fine on 3.0.0: import create from 'zustand'; type PlayState = 'playing' | 'paused' | 'stopped'; export interface ...
Read more >
How to satisfy the constraint of Record<string, unknown> with ...
TS says that MyInterface does not satisfy the constraint Record<string, unknown>. Is there any way around this other than to do
Read more >
Incorrect, "Type does not satisfy the constraint" error when ...
However, when R# is enabled it displays, "Type 'string' does not satisfy the constraint 'extends string | number' for type parameter 'TKey'.".
Read more >
Why is my Pick<> failing with "Type does not satisfy ... - Reddit
I have a file called ionIcons.ts. It contains a list of var delcarations. export declare var accessibility: string; export declare var…
Read more >
Oracle® Text Reference 11g Release 2 (11.2)
Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, ...
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