Closed
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: