Skip to content

Type inference in conditional types doesn't work with overloads #21707

Closed
@falsandtru

Description

@falsandtru

cc @ahejlsberg

TypeScript Version: 2.7.0-dev.20180206

Search Terms:

Code

type Call<T extends () => any> = T extends () => infer R ? R : never;
type Cast<T> = Call<CastMap<T>>;
interface CastMap<T> {
  (this: ThisType<true>): true;
  (this: ThisType<false>): false;
  (this: ThisType<boolean>): boolean;
  (this: ThisType<void>): void;
}

type A = Cast<true>;

Expected behavior:

A is true.

Actual behavior:

A is void.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions