Skip to content

Add strict index checking to array access #1757

@nickofthyme

Description

@nickofthyme

Enable noUncheckedIndexedAccess to prevent runtime errors when accessing empty arrays.

Currently, there is no guard for accessing a value from an array.

function getThing(things: string[]): string {
  return things[0]; // currently does not throw even though this could be undefined
}

Metadata

Metadata

Assignees

Labels

APIChanges the external API typesinternalInternal changes with no external impact

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions