Skip to content

Fix 'any' and 'keyof any' in mapped types#19185

Merged
ahejlsberg merged 4 commits into
masterfrom
fixMappedTypesKeyofAny
Oct 14, 2017
Merged

Fix 'any' and 'keyof any' in mapped types#19185
ahejlsberg merged 4 commits into
masterfrom
fixMappedTypesKeyofAny

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

This PR fixes some inconsistencies relating to any and keyof any as the constraint type in a mapped type.
Specifically, the mapped types { [P in any]: T } and { [P in keyof any]: T } both now yield a type corresponding to { [x: string]: T }.

Fixes #19152.

@ahejlsberg ahejlsberg requested a review from mhegazy October 14, 2017 18:23
@mhegazy mhegazy added the Breaking Change Would introduce errors in existing code label Oct 14, 2017
@mhegazy mhegazy added this to the TypeScript 2.6.1 milestone Oct 14, 2017
@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Oct 14, 2017

Breaking change note, before this change a mapped type on any was realized into any, e.g. Partial<any> was any. after this change Partial<any> is { [x:string]: any }. This is more consistent overall.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Breaking Change Would introduce errors in existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mapped generic type with <any> parameter inferred as "any"

2 participants