I have this code:
let x1: (number | null)[] = [null, 1, 2, 3, null];
let x2: number[] = x1.filter( o => o !== null );
I am trying to filter the non-null value using filter
. VS code is giving me this error
Type ‘(number | null)[]’ is not assignable to type ‘number[]’. Type
‘number | null’ is not assignable to type ‘number’. Type ‘null’ is not
assignable to type ‘number’.ts(2322)
Thanks in advance.