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.

[Types] Strictly typed store allows invalid values

See original GitHub issue

I might be missing something, but shouldn’t following disallow invalidA and invalidB values to be used in a store? As it is at the moment I don’t get any error about them.

import create from 'zustand';

interface Store {
  count: number;
  increase: () => void;
}

const [useStore] = create<Store>(set => ({
  count: 0,
  invalidA: 0,
  increase: () => set(state => ({ count: state.count + 1 })),
  invalidB: () => set({ count: 0 })
}));

export default useStore;

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dai-shicommented, Sep 3, 2020

@csr632 Check #174 . It would mitigate both issues with new middleware.

0reactions
dai-shicommented, Sep 2, 2020
  1. structural typing
  2. context sensitive function

They are basically technical limitations, but could we somehow mitigate them?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Types] Strictly typed store allows invalid values #95 - GitHub
I assume that this is due to the structural/duck typing - any superset of Store is assignable to Store because it has all...
Read more >
TypeScript strictly typed: strict mode is not enough - Medium
Now, TypeScript will ask to tell when a value can be null ( strictNullChecks ), and when inference is not possible it will...
Read more >
What is a strongly typed programming language? - TechTarget
Strongly typed programming language refers to an idea that describes the enforcement of firm restrictions on mixing different data types and values.
Read more >
Typescript Discriminated Union allows invalid state
I am trying to use a Typescript Discriminated Union to model a rather common scenario when loading data asynchronously: type LoadingState ...
Read more >
Typed Forms - Angular
Angular provides the FormGroup type for forms with an enumerated set of keys, and a type called FormRecord , for open-ended or dynamic...
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