### π Search Terms noUncheckedIndexedAccess, findIndex, undefined ### π Version & Regression Information Tried 5.8.2 and nightly (5.9.0-dev.20250310). ### β― Playground Link https://www.typescriptlang.org/play/?noUncheckedIndexedAccess=true&ts=5.8.2#code/MYewdgzgLgBAhgJwQLhmArgWwEYFMEDaAujALwwECMANDAEy0DMRA3AFCiSwCWAJgB5l4SAHQAzbmF4BJKbn4AKQaQB8MZeToBKdtzEwFfQQEJyAWkpaYAbzYx7MTtHWoMOfEMSEjrOw6cgADa4IoEgAOZKOmwAvmxAA ### π» Code ```ts const arr: number[] = [1, 2, 3]; const idx = arr.findIndex(x => x == 2); if (idx != -1) { const x: number = arr[idx]; console.log(x); } ``` ### π Actual behavior ``` Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. ``` ### π Expected behavior Code 'compiles' without errors. ### Additional information about the issue _No response_
π Search Terms
noUncheckedIndexedAccess, findIndex, undefined
π Version & Regression Information
Tried 5.8.2 and nightly (5.9.0-dev.20250310).
β― Playground Link
https://www.typescriptlang.org/play/?noUncheckedIndexedAccess=true&ts=5.8.2#code/MYewdgzgLgBAhgJwQLhmArgWwEYFMEDaAujALwwECMANDAEy0DMRA3AFCiSwCWAJgB5l4SAHQAzbmF4BJKbn4AKQaQB8MZeToBKdtzEwFfQQEJyAWkpaYAbzYx7MTtHWoMOfEMSEjrOw6cgADa4IoEgAOZKOmwAvmxAA
π» Code
π Actual behavior
π Expected behavior
Code 'compiles' without errors.
Additional information about the issue
No response