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 on array does not correct types returned from map #35988

Closed
alzalabany opened this issue Jan 3, 2020 · 5 comments
Closed

Array filter on array does not correct types returned from map #35988

alzalabany opened this issue Jan 3, 2020 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@alzalabany
Copy link

Search Terms:
Type Array filter

Code

type T = { id:number };
const obj = [{id:1},{id:2},{id:3}]
const ids = [1,2,5];
const error:T[] = ids.map(id=>obj[id] ? obj[id] : false).filter(Boolean);

Expected behavior:
const error should be T[] only;

Actual behavior:
// error type is T | false

Related Issues:
7657

@MartinJohns
Copy link
Contributor

Duplicate of #32834, #31164, #24063, #16655. Was implemented by #29955, and broken by #31515.

Search terms used: filter boolean

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 6, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@OmgImAlexis
Copy link

@MartinJohns since this was broken by #31515 can we get a new issue open to track this? Otherwise you're just going to keep closing issues as duplicates.

@MartinJohns
Copy link
Contributor

@OmgImAlexis I'm not a member of the TypeScript team, so I have no say in this. But.. why get a new issue? There are existing issues about this, see my comment from before: #35988 (comment)

@OmgImAlexis
Copy link

The first two issues you linked were closed, I had assumed the others were too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants