Skip to content

Cannot use indexed access type on an intersection using keyof on constitutents #12625

Description

@DanielRosenwasser

This might be too complex, but in trying to work around #12624

interface Options<Data, Computed> {
    data?: Data
    computed?: Computed;
}

declare class Component<Data, Computed> {
    constructor(options: Options<Data, Computed>);

    get<K extends keyof Data | keyof Computed>(key: K): (Data & Computed)[K];
}

I get the following error

Type K cannot be used to index into type Data & Computed.

Which I believe should be valid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions