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.

[BUG] A new derived API causes Typescript error

See original GitHub issue

After 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
  1. I use explicit typing:
declare module 'overmind' {
  interface Config
    extends IConfig<{
      state: typeof state;
      actions: typeof actions;
      effects: typeof effects;
    }> {}
}
  1. 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:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
suevalovcommented, Jun 9, 2020

@christianalfoni just check it out and it fixes the issue 🎉

huge thanks as usual 💯

0reactions
christianalfonicommented, Jun 9, 2020

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

Read more comments on GitHub >

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

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