Bug Report
π Search Terms
noUncheckedIndexAccess, array
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about noUncheckedIndexAccess
β― Playground Link
Playground link with relevant code
π» Code
With noUncheckedIndexAccess enabled:
constarr: string[]=[];typeIncorrectArrayType=typeofarr[0];// string// there's a workaround, but it involves runtime overheadconstcorrect=arr[0];typeCorrectArrayType=typeofcorrect;// string | undefined
π Actual behavior
Indexing an array type doesn't include undefined with noUncheckedIndexAccess enabled
π Expected behavior
IncorrectArrayType should be string | undefined
Bug Report
π Search Terms
noUncheckedIndexAccess, array
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
With
noUncheckedIndexAccessenabled:π Actual behavior
Indexing an array type doesn't include
undefinedwith noUncheckedIndexAccess enabledπ Expected behavior
IncorrectArrayTypeshould bestring | undefined