3 ms·
Type guards also allow you to use Array.prototype.filter to modify the type of an array ie const maybePets: Array<Pet | undefined> = [...] const pets: Arra
by drabinowitz 8y ago
Type guards also allow you to use Array.prototype.filter to modify the type of an array ie
const maybePets: Array<Pet | undefined> = [...]
const pets: Array<Pet> = maybePets.filter((v: Pet | undefined): v is Pet => v != undefined)
Will compile without errors.