[BUG] A new derived API causes Typescript error
See original GitHub issueAfter upgrading to overmind@24.0.0
I see the following Typescript error:
TS2345: Argument of type ‘(state: State) => string’ is not assignable to parameter of type ‘(state: IState, rootState: IState) => any’. Types of parameters ‘state’ and ‘state’ are incompatible. Type ‘IState’ is missing the following properties from type ‘State’: defaultLocaleCode, list
- Typescript version: 3.9.5
- Overmind version: 24.0.0
- I use explicit typing:
declare module 'overmind' {
interface Config
extends IConfig<{
state: typeof state;
actions: typeof actions;
effects: typeof effects;
}> {}
}
- Code to reproduce the error:
import { derived } from 'overmind';
import { Locale } from 'core/typings';
export type State = {
defaultLocaleCode: string;
list: Locale[];
};
export const state: State = {
defaultLocaleCode: derived((state: State) => { // <------- here typescript complains
return state.list.find((locale) => locale.default === true)?.code ?? 'en-US';
}),
list: [],
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
TypeScript errors and how to fix them
Common Errors Below you find a list of common TypeScript errors along with the buggy code and its fixed version.
Read more >Error when trying to inject a service into an angular ...
I have the service in the bootstrap function so it has a provider. And I seem to be able to inject it into...
Read more >Expressive error handling in TypeScript and benefits ... - Medium
Correctly handling and throwing errors in Javascript, or Typescript in our case, is always a painful experience and a journey with many ...
Read more >TypeError - JavaScript - MDN Web Docs
TypeError is a serializable object, so it can be cloned with structuredClone() or copied between Workers using postMessage() . Constructor.
Read more >Troubleshooting common React Native bugs - LogRocket Blog
It's still tricky because, as you can see, the error is caused by a ... However, this can trigger new errors, especially if...
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
@christianalfoni just check it out and it fixes the issue 🎉
huge thanks as usual 💯
Okay, so pushed a fix to
next
where this typing is fixed.If you want to use it, make sure you install all overmind packages with the
@next
tag.When this one is ready, it is available: https://travis-ci.org/github/cerebral/overmind/builds/696549177