Skip to content
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

Conditional types can't resolve keyof this #21862

Closed
falsandtru opened this issue Feb 10, 2018 · 3 comments
Closed

Conditional types can't resolve keyof this #21862

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

Comments

@falsandtru
Copy link
Contributor

cc @ahejlsberg

TypeScript Version: 2.7.0-dev.20180210

Search Terms:

Code

type OldDiff<T extends string, U extends string> = (
  & { [P in T]: P; }
  & { [P in U]: never; }
  & { [x: string]: never; }
)[T];
type NewDiff<T, U> = T extends U ? never : T;
interface A {
  a: 'a';
}
interface B1 extends A {
  b: 'b';
  c: OldDiff<keyof this, keyof A>;
}
interface B2 extends A {
  b: 'b';
  c: NewDiff<keyof this, keyof A>;
}
type c1 = B1['c']; // 'c' | 'b'
type c2 = B2['c']; // 'c' | 'a' | 'b'

Expected behavior:

c2 is 'c' | 'b'.

Actual behavior:

c2 is 'c' | 'a' | 'b'.

Playground Link:

Related Issues:

@falsandtru
Copy link
Contributor Author

@ahejlsberg Is this not a bug?

@ahejlsberg
Copy link
Member

@falsandtru Don't know yet, haven't had time to look.

@falsandtru
Copy link
Contributor Author

I see.

@ahejlsberg ahejlsberg self-assigned this Feb 14, 2018
@ahejlsberg ahejlsberg added the Bug A bug in TypeScript label Feb 14, 2018
@ahejlsberg ahejlsberg added this to the TypeScript 2.8 milestone Feb 14, 2018
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Feb 14, 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

2 participants