Skip to content

Conditional types don't work through other types #21664

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 6, 2018 · 0 comments
Closed

Conditional types don't work through other types #21664

falsandtru opened this issue Feb 6, 2018 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@falsandtru
Copy link
Contributor

falsandtru commented Feb 6, 2018

cc @ahejlsberg

TypeScript Version: master

Search Terms:

Code

type Eq_<T, U> = T extends U ? U extends T ? true : false : false;
(): true => true as Eq_<true, true>;
(): false => true as Eq_<true, false>;
(): false => true as Eq_<false, true>;
(): true => true as Eq_<false, false>;

type Eq<T, U> = Eq_<T, U> extends false ? false : true;
(): true => true as Eq<true, true>;
(): false => true as Eq<true, false>;
(): false => true as Eq<false, true>;
(): true => true as Eq<false, false>;

also

type Eq<T, U> = If<T extends U ? U extends T ? true : false : false, true, false>;
type If<S, T, U> = S extends false ? U : T;

Expected behavior:

pass

Actual behavior:

$ node built/local/tsc.js --noEmit index.ts
index.ts(9,14): error TS2322: Type 'true' is not assignable to type 'false'.
index.ts(10,14): error TS2322: Type 'true' is not assignable to type 'false'.

Playground Link:

Related Issues:

@mhegazy mhegazy added the Bug A bug in TypeScript label Feb 6, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Feb 6, 2018
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue 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
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants