Skip to content

Conversation

ahejlsberg
Copy link
Member

This PR changes the assignability of an unconstrained indexed access to be the same as that of an unconstrained type parameter. Specifically, an unconstrained type parameter is assignable to {} and with this PR the same is true for an unconstrained indexed access.

function foo<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]) {
    let a: {} | null | undefined;
    a = x;  // Ok
    a = y;  // Ok, but was error before this PR
    a = z;  // Ok, but was error before this PR
}

Fixes #21368.
Fixes #23133.

@ahejlsberg ahejlsberg added this to the TypeScript 2.9 milestone Apr 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants