Skip to content

Incorrect overload resolution in 3.2.0-rc #28567

Closed
@Jessidhia

Description

@Jessidhia

TypeScript Version: 3.2.0-rc

Search Terms:
Overload

Code

import { createStore } from 'redux'

const initialStore: { foo: {} } = { foo: {} }
const store = createStore(x => x, initialStore)

Expected behavior:

The second overload of createStore should be chosen, as initialStore is not a StoreEnhancer but a preloadedState.

Actual behavior:

The StoreEnhancer, a function, overload of createStore is chosen despite initialStore being absolutely, definitely not a function, causing the type of x to be incorrectly inferred as {} | undefined.

Metadata

Metadata

Assignees

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions