Bug Report
π Search Terms
noUncheckedIndexedAccess
π Version & Regression Information
4.2.0-dev.20210124
β― Playground Link
https://www.typescriptlang.org/play?noUncheckedIndexedAccess=true&ts=4.2.0-dev.20210124#code/CYUwxgNghgTiAEYD2A7AzgF3gMyUgXPCgK4C2ARiDANoC6AsAFBMYCeADggGJ7wC88NpyTYceagEZa8APQySFKkybJ0WcrEI8k-MUknS5AFQ4IA5Asox4AH3jEUobAEsUIYGfjO0RJFihoaM4A5ihQ5BAIGDpC5pZUZkA
Playground link with relevant code
π» Code
declare const foo: number[]
type Foo = typeof foo[1] //number
const bar: Foo = foo[1] //Type 'number | undefined' is not assignable to type 'number'
π Actual behavior
typeof foo[1] returns number, but the actual type is number|undefined
π Expected behavior
typeof foo[1] should return number | undefined when noUncheckedIndexedAccess is enabled