Closed
Description
Bug Report
π Search Terms
filter Boolean undefined
π Version & Regression Information
- Latest version
β― Playground Link
Playground link with relevant code
π» Code
type Model = { id: string }
const models: Model[] = [{ id: '0' }, { id: '1' }, { id: '2' }]
const ids = ['1', '3']
const values = ids
.map(id => models.find(model => model.id === id))
.filter(model => model !== undefined) // values type should be Model[]
π Actual behavior
values
is of type (Model | undefined)[]
even though undefined values are excluded thanks to the filter function
π Expected behavior
values
should be of type Model[]