typescript filter undefined code example Example: typescript filter undefined array.filter((x): x is MyType => x !== null);