Skip to content

Cannot access indexed type of constrained type parameter #12340

Closed
@HerringtonDarkholme

Description

@HerringtonDarkholme

Related: #12311

TypeScript Version: nightly
Code

type Boxed = {
    [k in string]: {value: any}
}

type Unboxed<T extends Boxed> = {
    [K in keyof T]: T[K]['value']
}

Expected behavior:
Should compile since Boxed has index signature. T with constraint Boxed should also be indexable, with T[K] constrained by Boxed's value type, in this case, {value: any}

Actual behavior:

Error, Property 'value' does not exist on type 'T[K]'

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions