Skip to content

Higher order type inference doesn't work with overloads #33594

Description

Anders Hejlsberg (@ahejlsberg)

TypeScript Version: typescript@3.7.0-dev.20190925

Search Terms:

Code

interfaceCurried2<a,b,z>{(a: a,b: b): z;(a: a): (b: b)=>z;}interfaceCurry{<a,b,z>(f: (a: a,b: b)=>z): Curried2<a,b,z>;}declareconstcurry: Curry;curry(<Textends0,Uextends1>(n: T,m: U)=>n+m)(1)(0);curry(<Textends0,Uextends1>(n: T,m: U)=>n+m)(1,0);

Also the following doesn't work:

interfaceCurried2<a,b,z>{(a: a): (b: b)=>z;(a: a,b: b): z;}

When removing overloads as follows:

interfaceCurried2<a,b,z>{(a: a,b: b): z;}

or

interfaceCurried2<a,b,z>{(a: a): (b: b)=>z;}

These work correctly.

Expected behavior:

Infer type parameters correctly and all parameter values are rejected correctly.

Actual behavior:

no error.

Playground Link:

Related Issues:

Metadata

Metadata

Labels

SuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions