const startedTests = tests.filter(test => test.thread_id !== null);
tests if of type
{
thread_id: string | null
}[]
But after the filter() operation
for (
const thread of startedTests.reduce((accumulator, currentValue) => {
accumulator.push(currentValue.thread_id); // Argument of type 'string | null' is not assignable to parameter of type 'string'. Type 'null' is not assignable to type 'string'.
return accumulator;
}, (<string[]> []))
) {
// code
}
Why is typescript considering thread_id as possibly null if tests with a null thread_id value are filtered out?