Skip to content

Return type inference of overloaded function when argument is known #27027

@KSXGitHub

Description

@KSXGitHub

TypeScript Version: 3.0.3

Search Terms:

Code

declare function fn(x: 'a'): 0
declare function fn(x: 'b'): 1
declare function fn(x: 'c'): 2
declare function fn(x: 'D'): 3

// expected: type One = 1
// received: type One = never
type One = (typeof fn) extends (x: 'b') => infer Return ? Return : never
const one: One = 1

Expected behavior:

One should be 1

Actual behavior:

One is never

Playground Link: link

Related Issues: #26591

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