-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: 4.1.0-dev.20200920
Search Terms:
- noUncheckedIndexedAccess
- Pedantic Index Signatures
- variadic tuples
Code
type NonEmptyStringArray = [string, ...Array<string>]
const strings: NonEmptyStringArray = ['one', 'two', 'three']
strings[0].toUpperCase()
strings[99].toUpperCase()Expected behavior:
strings[99].toUpperCase() should type error
Actual behavior:
strings[99].toUpperCase() shows no type error
Please note that if you change const strings to Array<string>, every index access correctly yields a type error.
Playground Link:
Related Issues:
IllusionMH and cosimochellini
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue