The find and filter methods should allow for typeguards, just like their array counterparts, while still allowing non-type guard methods that simply return a boolean value
declare const arr: (string|number)[];
const filteredArr = arr.filter(v => typeof v == "number"); // number[]
const noGuard = arr.filter(v => (""+v).length > 0); // (string|number)[]
Expected Behaviour
Type is narrowed
declare const arr: List<string|number>;
const filteredList = list.filter(v => typeof v == "number"); // List<number>
const filteredValue = list.find(v => typeof v == "number"); // number
Actual Behaviour
Type is not narrowed
declare const arr: List<string|number>;
const filteredList = list.filter(v => typeof v == "number"); // List<string|number>
const filteredValue = list.find(v => typeof v == "number"); // string|number
The
findandfiltermethods should allow for typeguards, just like their array counterparts, while still allowing non-type guard methods that simply return abooleanvalueExpected Behaviour
Type is narrowed
Actual Behaviour
Type is not narrowed