Closed
Description
Bug Report
π Search Terms
noUncheckedIndexedAccess destructuring tuple rest elements
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
Playground link with relevant code
π» Code
type NonEmptyStringArray = [string, ...Array<string>]
const strings: NonEmptyStringArray = ['one', 'two', 'three']
const [s0, s1, s2, s3] = strings;
// ^? const s3: string | undefined
s3.toUpperCase()
//^? const s3: string
π Expected behavior
s3.toUpperCase()
shows type error.
π Actual behavior
s3.toUpperCase()
shows no error.
Note that undefined
is correctly included inside the assignment statement but then lost.
Related: #40657