Title: functions with destructuring parameters are not inferred as type predicate correctly · Issue #59497 · microsoft/TypeScript · GitHub
Open Graph Title: functions with destructuring parameters are not inferred as type predicate correctly · Issue #59497 · microsoft/TypeScript
X Title: functions with destructuring parameters are not inferred as type predicate correctly · Issue #59497 · microsoft/TypeScript
Description: 🔎 Search Terms infer type predicate, destructuring 🕗 Version & Regression Information This changed between versions 5.5 This changed in commit or PR _______ This is the behavior in every version I tried, and I reviewed the FAQ for entrie...
Open Graph Description: 🔎 Search Terms infer type predicate, destructuring 🕗 Version & Regression Information This changed between versions 5.5 This changed in commit or PR _______ This is the behavior in every version I ...
X Description: 🔎 Search Terms infer type predicate, destructuring 🕗 Version & Regression Information This changed between versions 5.5 This changed in commit or PR _______ This is the behavior in every versio...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/59497
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"functions with destructuring parameters are not inferred as type predicate correctly","articleBody":"### 🔎 Search Terms\n\ninfer type predicate, destructuring\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 5.5\r\n- This changed in commit or PR _______\r\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________\r\n- I was unable to test this on prior versions because _______\r\n\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?#code/C4TwDgpgBAGlC8UDeVSQFxQOQEEsG4oBDTAZ2ACcBLAOwHMoBfKAH2VXAkywCECoARmUq0GjfACgANhGBQAHqUwwA2gF0EUdZIkB6XVFIALAPYBXKQBMoNE3IgUKJihIDGJmuSgAzKlOAOEJYAjJgoaFzYeIQkhiL0TOqaihJQUAB0vv4OABQ54ZxMAJQIAHwckAjwiLhYRTrunnJZARRBAExhFZG1McLUCYxJiClpmX6tOfJlCukRVTV49RJAA\n\n### 💻 Code\n\n```ts\r\ntype X = { type: 'A'; a: string } | { type: 'B'; b: string };\r\nlet xs: X[] = [];\r\n\r\n// should not error\r\nconst filtered1: { type: 'A'; a: string }[] = xs\r\n .filter(({ type }) => type === 'A');\r\n\r\nconst filtered2: { type: 'A'; a: string }[] = xs\r\n .filter(x => x.type === 'A');\r\n```\r\n\n\n### 🙁 Actual behavior\n\nerror on filtered1\n\n### 🙂 Expected behavior\n\nnot error on filtered1\n\n### Additional information about the issue\n\n_No response_","author":{"url":"https://github.com/Zzzen","@type":"Person","name":"Zzzen"},"datePublished":"2024-08-01T13:29:43Z","url":"https://github.com/microsoft/TypeScript/issues/59497"}
| 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:0a26338e-44b9-c8b4-a8c8-fd813f6cbce5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7A8:1201C:C3A1D2:105B4A4:6B00F715 |
| html-safe-nonce | 4e476f12d67381556fd28bbe29315f17388876ad1b0cf7e306729819f039e4cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0E4OjEyMDFDOkMzQTFEMjoxMDVCNEE0OjZCMDBGNzE1IiwidmlzaXRvcl9pZCI6Ijc0NzI1MDkyMDcxODM0MjMyNTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5f490ffc36987f632f7cf4f4a33614b8d5aa2c622d24d99d2a9e5fec321b4f4a |
| hovercard-subject-tag | issue:2442472207 |
| 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/59497/issue_layout |
| twitter:image | https://opengraph.githubassets.com/50424bed4ddbabef3ea9e7852ce9f4629d815f05e0000db1c1273b102c49ff26/microsoft/TypeScript/issues/59497 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/50424bed4ddbabef3ea9e7852ce9f4629d815f05e0000db1c1273b102c49ff26/microsoft/TypeScript/issues/59497 |
| og:image:alt | 🔎 Search Terms infer type predicate, destructuring 🕗 Version & Regression Information This changed between versions 5.5 This changed in commit or PR _______ This is the behavior in every version I ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Zzzen |
| 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