Title: Array filter on array does not correct types returned from map · Issue #35988 · microsoft/TypeScript · GitHub
Open Graph Title: Array filter on array does not correct types returned from map · Issue #35988 · microsoft/TypeScript
X Title: Array filter on array does not correct types returned from map · Issue #35988 · microsoft/TypeScript
Description: 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[] o...
Open Graph Description: 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); Expect...
X Description: 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); Exp...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/35988
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Array filter on array does not correct types returned from map","articleBody":"**Search Terms:**\r\nType Array filter\r\n\r\n**Code**\r\n```ts\r\ntype T = { id:number };\r\nconst obj = [{id:1},{id:2},{id:3}]\r\nconst ids = [1,2,5];\r\nconst error:T[] = ids.map(id=>obj[id] ? obj[id] : false).filter(Boolean);\r\n```\r\n\r\n**Expected behavior:**\r\n`const error` should be T[] only;\r\n\r\n**Actual behavior:**\r\n// error type is T | false\r\n\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n[7657](https://github.com/microsoft/TypeScript/issues/7657)","author":{"url":"https://github.com/alzalabany","@type":"Person","name":"alzalabany"},"datePublished":"2020-01-03T22:36:39Z","url":"https://github.com/microsoft/TypeScript/issues/35988"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a82a54c8-ebea-8a2a-dee6-b88cfbf3373c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B630:11EACE:AFC4C1:EBC44E:6B00F214 |
| html-safe-nonce | 0abc2a0f9613c9e7e6b340f8fe3ece85ef76d075e81a11fe4d3413642dd134c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjMwOjExRUFDRTpBRkM0QzE6RUJDNDRFOjZCMDBGMjE0IiwidmlzaXRvcl9pZCI6IjYxNDU5OTc4NTQ3NTUzMjAzNDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b67485e8e5380e6d302b0785669ca9eaa5a55426b8e516e509896aa6b89db1f5 |
| hovercard-subject-tag | issue:545192379 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/35988/issue_layout |
| twitter:image | https://opengraph.githubassets.com/159ef7e442752520776bc78e42d14778e80d7016a9b4f12a3d691c916277cb69/microsoft/TypeScript/issues/35988 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/159ef7e442752520776bc78e42d14778e80d7016a9b4f12a3d691c916277cb69/microsoft/TypeScript/issues/35988 |
| og:image:alt | 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); Expect... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alzalabany |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width