Skip to content

Generics not being inferred in complex case #9107

Closed
@michaelmesser

Description

@michaelmesser

TypeScript Version:

Typescript playground

Code

const compose = <In, Intermediate_Big, Intermediate_Small extends Intermediate_Big, Out>(f: (x: In)=> Intermediate_Small, g: (x: Intermediate_Big) => Out): (a1: In) => Out => (_ => g(f(_)))
const first = <T>(a: T[]): T => a[0]
const getText = (_: HTMLElement) => _.innerText
const c = compose(first, getText)

Expected behavior:
c is of type (x: HTMLElement[]) => string
Actual behavior:
c is of type (x: {}) => string

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions