Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Improve Typescript dispatch reducers inference #894

@semoal

Description

@semoal
import { createModel } from '@rematch/core'
import { delay } from './utils'
import type { RootModel } from '.'

export const dolphins = createModel<RootModel>()({
	state: 0,
	reducers: {
		increment: (state, payload = 1) => state + payload,
	}
})

Describe the bug

Actually the payload = 1 is infered as any and when dispatching the reducer says that: (property) increment: () => Action<void, void>, doesn't expect a payload...

The same occurs if the payload it's optional

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions