Skip to content

Simplified typing #481

@christianalfoni

Description

@christianalfoni

Dear Overminders!

I have one thing I really want to do and that is to clean up and simplify the typing of Overmind. It was a long process figuring out how to do it and with acquired knowledge through all this work and later projects I would like to do this:

import { IContext } from 'overmind'

const config = { ... }

export interface Context extends IContext<{
  state: typeof config.state,
  actions: typeof config.actions,
  effects: typeof config.effects
}> {}

There will be no more implicit typing, the above is what everybody will need to do. This is how you type the different things:

const myAction = (context: Context) => {}

const myActionWithPayload = (context: Context, payload: string) => {}

// Now we support generics
const myActionWithPayload = <T extends TEvent>(context: Context, payload: T) => {}

const myOperator = map((context: Context, value: string) => {})

const state: State = {
  someDerived: derived((state: State, rootState: Context["state"]) => {})
}

And I believe that is it. This will need to be a breaking change to actually clean up the internal typing of Overmind. I was just wondering how you feel about this change, do you consider refactoring your apps to this typing too much work? 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions