1function notEmpty<TValue>(value: TValue | null | undefined): value is TValue {
2 return value !== null && value !== undefined;
3}
4
5const array: (string | null)[] = ['foo', 'bar', null, 'zoo', null];
6const filteredArray: string[] = array.filter(notEmpty);