-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect overload resolution in 3.2.0-rc #28567
Comments
The error is not that we're picking the wrong overload, but rather that none of the overloads are applicable. Here's a simplified repro: declare function test<T>(f: (x: T | undefined) => T, enhancer: () => void): T;
declare function test<T>(f: (x: T | undefined) => T, state: T): T;
test(x => x, { a: 'hello' }); // Ok in 3.1, error in 3.2
test(x => x || { a: 'xxx' }, { a: 'hello' }); // Ok in both The correct inference for The reason it succeeds in 3.1 is somewhat subtle: We do multiple passes on the overloaded signatures, initially making an inference of The fact that 3.1 gets it wrong becomes obvious if you comment out the first overload (which shouldn't really matter as it is not applicable). 3.1 then behaves the same as 3.2. |
I see. This is likely then an error with the |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
TypeScript Version: 3.2.0-rc
Search Terms:
Overload
Code
Expected behavior:
The second overload of
createStore
should be chosen, asinitialStore
is not aStoreEnhancer
but apreloadedState
.Actual behavior:
The
StoreEnhancer
, a function, overload ofcreateStore
is chosen despiteinitialStore
being absolutely, definitely not a function, causing the type ofx
to be incorrectly inferred as{} | undefined
.The text was updated successfully, but these errors were encountered: