Skip to content
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

Inference breaks when a function returns a tuple with another function #44476

Open
vitalyq opened this issue Jun 7, 2021 · 1 comment
Open
Labels
Bug A bug in TypeScript
Milestone

Comments

@vitalyq
Copy link

vitalyq commented Jun 7, 2021

Bug Report

πŸ”Ž Search Terms

Inference, tuple, generic, callback, higher-order function

πŸ•— Version & Regression Information

v4.3.2 and below (tested down to v3.3.3)

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare function a(): [
  <T>(arg: T) => T
]

declare function b<T, U>(a1: T, a2: [(a: T) => U]): U

b(1, [a()[0]]) // returns number, as expected
b(1, a()) // returns unknown (expected a number)
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jun 8, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 8, 2021
@RyanCavanaugh
Copy link
Member

Looks like there's an incorrect inference priority being assigned here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants