// Cast to any to simulate incoming API value
const array: string[] | undefined | null = ['aa'] as any;
const isValid = Boolean(array && array.length > 0);
// Error on `array.map` for possible null or undefined, while we already verified the existence & length before
if (isValid) array.map(e => console.log(isValid));
π Actual behavior
Gives an error for undefined/null, while we already verified the existence & length before
π Expected behavior
Pass typings check as we already established it's existance
Additional information about the issue
Honestly don't know how to describe such check for better tags
π Search Terms
Boolean, null/undefined
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.6.3#code/MYewdgzgLgBAhgJwXAngLhtBBLMBzAbQF0YAfGAVzABMBTAM11urJjAoBsOYBeGAgORw4AknAjwwKANwAoWaEixsEAGpwO2FnwBCIEB1pwwACkTIUMAGRX4SVADpD+KAAsYAPhgAGAJRzZbHoYExV1TWpfOwsHAFs4AAcTWl4vRQgDWicQPFC1DS1ffxgAehKYAFEkEAQAGhgAd1dsQ0aUjQQjaksAN1ocRmYYNxTaAA8VKGNgFNtnPDcYACMGGtogA
π» Code
π Actual behavior
Gives an error for undefined/null, while we already verified the existence & length before
π Expected behavior
Pass typings check as we already established it's existance
Additional information about the issue
Honestly don't know how to describe such check for better tags