Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array.filter() should have an overload for type guards #15847

Closed
felixfbecker opened this issue May 15, 2017 · 2 comments
Closed

array.filter() should have an overload for type guards #15847

felixfbecker opened this issue May 15, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@felixfbecker
Copy link
Contributor

const a = [1, '2', 3]; // (number | string)[]
const b = a.filter(el => typeof el === 'number') // still (number | string)[], expected number[]

array.filter() should have an overload:

filter(predicate: (el: T, i, arr) => el is R): R[]

The same kind of overload is in rxjs' filter operator.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label May 15, 2017
@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented May 15, 2017

Please search. #7657

image

@felixfbecker
Copy link
Contributor Author

mea culpa, I thought something seemingly simple as this would either be implemented already or not have an open issue.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants