I have an array of object, one of the property has a null value, I used filter to remove it, but typescript give me warning null is not assignable? since filter will never return null why typescript give me such an error?
const data = [
{
id: "123"
},
{
id: "456"
},
{
id: null
}
];
const d2: string[] = data.map((d) => d.id).filter((o) => o);
console.log(d2);
demo https://codesandbox.io/s/gallant-water-vio56?file=/src/index.ts:0-165