[Types] Strictly typed store allows invalid values
See original GitHub issueI 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:
- Created 4 years ago
- Comments:12 (9 by maintainers)
Top 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 >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
@csr632 Check #174 . It would mitigate both issues with new middleware.
They are basically technical limitations, but could we somehow mitigate them?