Skip to content

Regression - able to use union containing non-indexing type as index #26714

Closed
@RyanCavanaugh

Description

@RyanCavanaugh

TypeScript Version: master at bd40583

Search Terms: array index union error

Code

declare const arr1: (string | string[])[];
declare const arr2: number[];
const j = arr2[arr1[0]];

Expected behavior: Error - Type string[] cannot be used as an index type

Actual behavior: No error

Playground Link: Link

Related Issues: Regressed during fix of #26409 (edit: #26281 ?)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions