Tried 5.8.2 and nightly (5.9.0-dev.20250310).
const arr: number[] = [1, 2, 3];
const idx = arr.findIndex(x => x == 2);
if (idx != -1) {
const x: number = arr[idx];
console.log(x);
}
Type 'number | undefined' is not assignable to type 'number'.
Type 'undefined' is not assignable to type 'number'.
Code 'compiles' without errors.