Skip to content

Checker loses the Array subclass element type for a union of canonical string keys #3623

Closed

Description

@nickna
class Child<T> extends Array<T> {}
function read(child: Child<number>, key: '0' | '1') {
    const wrong: string = child[key];
}

TypeScript 6.0.3 with --ignoreConfig --strict --target ES2022 --noEmit reports TS2322 on wrong because both keys address numeric elements. SharpTS accepts the assignment with --no-tsconfig --strict --noEmit.

#3599 tracks a single canonical string key and also covers union receivers. This reproduction uses a union of keys and a single receiver.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions