Skip to content

Issues indexing with unique symbols on generic types #22320

Closed
@DanielRosenwasser

Description

@DanielRosenwasser

Found helping @bterlson with something.

Basically, the main issue is that as soon as I use an indexed access type with a unique symbol on a type parameter, things fall apart.

declare const fooProp: unique symbol;

export interface Foo<T> {
  [fooProp]: T
}

function f<T extends Foo<any>>(x: T) {
    const abc = x[fooProp] // expected: 'T[typeof fooProp]'; actual: 'any'

    /**
     * Expected: no error
     * Actual: Type 'unique symbol' cannot be used to index type 'T'.
     */
    const def: T[typeof fooProp] = x[fooProp]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions