Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
falsandtru opened this issue Feb 7, 2018 · 0 comments
Closed

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

falsandtru opened this issue Feb 7, 2018 · 0 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@falsandtru
Copy link
Contributor

falsandtru commented Feb 7, 2018

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:

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Feb 7, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants
@falsandtru @mhegazy and others