Skip to content

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

Open
@vitalyq

Description

@vitalyq

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions