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

Mapped types with direct and aliased keyof usage #12602

Closed
arusakov opened this issue Dec 1, 2016 · 1 comment
Closed

Mapped types with direct and aliased keyof usage #12602

arusakov opened this issue Dec 1, 2016 · 1 comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@arusakov
Copy link
Contributor

arusakov commented Dec 1, 2016

TypeScript Version: master (fc1f6e3)

Code

type X = {
  a?: any;
  b: any;
}

type Keys = keyof X;

type Direct = {
  [K in keyof X]: any;
}
// type Direct = {
//   a?: any; - optional
//   b: any;
// }

type WithAlias = {
  [K in Keys]: any;
}
// type WithAlias = {
//   a: any; - required
//   b: any;
// }

Expected behavior:
Types Direct and WithAlias have the same a property. I think that a property must be required in both Direct and WithAlias types.

Actual behavior:
Types Direct and WithAlias have different a property (optional and required).

@ahejlsberg
Copy link
Member

This is working as intended. See #12563.

@ahejlsberg ahejlsberg added the Working as Intended The behavior described is the intended behavior; this is not a bug label Dec 1, 2016
@arusakov arusakov closed this as completed Dec 1, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

2 participants