Title: 7.1: destructured parameter with a `= {}` default loses its contextual type (TS7031) · Issue #64974 · microsoft/TypeScript · GitHub
Open Graph Title: 7.1: destructured parameter with a `= {}` default loses its contextual type (TS7031) · Issue #64974 · microsoft/TypeScript
X Title: 7.1: destructured parameter with a `= {}` default loses its contextual type (TS7031) · Issue #64974 · microsoft/TypeScript
Description: 🔎 Search Terms TS7031, binding element implicitly has an any type, destructuring parameter default, contextual type, 7.1 regression 🕗 Version & Regression Information This changed between versions 7.0.2 and 7.1.0-beta Still present in 7....
Open Graph Description: 🔎 Search Terms TS7031, binding element implicitly has an any type, destructuring parameter default, contextual type, 7.1 regression 🕗 Version & Regression Information This changed between versions ...
X Description: 🔎 Search Terms TS7031, binding element implicitly has an any type, destructuring parameter default, contextual type, 7.1 regression 🕗 Version & Regression Information This changed between versi...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/64974
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"7.1: destructured parameter with a `= {}` default loses its contextual type (TS7031)","articleBody":"### 🔎 Search Terms\n\nTS7031, binding element implicitly has an any type, destructuring parameter default, contextual type, 7.1 regression\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 7.0.2 and 7.1.0-beta\n- Still present in 7.1.0-dev.20261026.1\n- 6.0.3 and 7.0.2 report no errors\n\n### ⏯ Playground Link\n\n_No response_\n\n### 💻 Code\n\n```ts\n// tsconfig: { \"compilerOptions\": { \"strict\": true, \"noEmit\": true, \"skipLibCheck\": true, \"types\": [] } }\ntype Fn = (input?: { channel?: string; minutes?: number }) => number;\nexport const f: Fn = ({ channel, minutes } = {}) => (channel ? 1 : 0) + (minutes ?? 0);\n```\n\nThe error needs all three of: a destructuring pattern, an `= {}` initializer, and a contextually typed optional parameter. Each of these alone still checks cleanly on 7.1:\n\n```ts\ntype F2 = (input: { channel?: string; minutes?: number }) => number;\nexport const f2: F2 = ({ channel, minutes }) => (channel ? 1 : 0) + (minutes ?? 0); // no initializer: OK\n\ntype G = (input?: { channel?: string }) => number;\nexport const g: G = (input = {}) => (input.channel ? 1 : 0); // identifier, not a pattern: OK\n```\n\n### 🙁 Actual behavior\n\n```\na.ts(2,25): error TS7031: Binding element 'channel' implicitly has an 'any' type.\na.ts(2,34): error TS7031: Binding element 'minutes' implicitly has an 'any' type.\n```\n\n### 🙂 Expected behavior\n\nNo errors: `channel` and `minutes` take their types (`string | undefined`, `number | undefined`) from the contextual parameter type, as on 6.0.3 and 7.0.2.\n\n### Additional information about the issue\n\nFound while trialling 7.1.0-beta on a large monorepo; it fires in test helpers and callbacks typed through an alias (`({ a, b } = {}) => …` assigned to a function type with an optional object parameter).\n","author":{"url":"https://github.com/raimonade","@type":"Person","name":"raimonade"},"datePublished":"2026-10-26T22:31:46Z","url":"https://github.com/microsoft/TypeScript/issues/64974"}
| 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:b8fc50e7-c972-bb4f-259c-a505ce2aba91 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C4CA:1DB641:BFB002:F83888:6B00EB9E |
| html-safe-nonce | f4f653f133829a6cbfb245ad23efc46606c98ef643d10fac7cdbf60722406bfa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNENBOjFEQjY0MTpCRkIwMDI6RjgzODg4OjZCMDBFQjlFIiwidmlzaXRvcl9pZCI6IjU5Nzc5MzUwODg2NzgxMzY3MzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a467ba7b7dff71d60f76e3cc828aa2b853257cc75f61f1f7025fb4752273ff75 |
| hovercard-subject-tag | issue:6049341337 |
| 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/64974/issue_layout |
| twitter:image | https://opengraph.githubassets.com/89131550fd6a09e116b6cf859bb5eb2302f106882a9e02ab432e51fae55177b7/microsoft/TypeScript/issues/64974 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/89131550fd6a09e116b6cf859bb5eb2302f106882a9e02ab432e51fae55177b7/microsoft/TypeScript/issues/64974 |
| og:image:alt | 🔎 Search Terms TS7031, binding element implicitly has an any type, destructuring parameter default, contextual type, 7.1 regression 🕗 Version & Regression Information This changed between versions ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | raimonade |
| 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 | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width