Why can’t TypeScript infer type from filtered arrays?
A few things are going on here. The first (minor) issue is that, with your Student interface, the compiler will not treat checking the isValid property as a type guard: const s = students[Math.random() < 0.5 ? 0 : 1]; if (s.isValid) { foo([s]); // error! // ~ // Type ‘Student’ is not assignable to … Read more