Title: Bug: Functional properties make inference non-working in case of circular type parameter constraints like T extends M
Open Graph Title: Bug: Functional properties make inference non-working in case of circular type parameter constraints like T extends M
X Title: Bug: Functional properties make inference non-working in case of circular type parameter constraints like T extends M
Description: Bug Report 🔎 Search Terms Circular type parameter constraint, inference change due to presence of functional property Related: #40439 🕗 Version & Regression Information Tested with v4.3.4 ⏯ Playground Link Playground 💻 Code declare const...
Open Graph Description: Bug Report 🔎 Search Terms Circular type parameter constraint, inference change due to presence of functional property Related: #40439 🕗 Version & Regression Information Tested with v4.3.4 ⏯ Playgro...
X Description: Bug Report 🔎 Search Terms Circular type parameter constraint, inference change due to presence of functional property Related: #40439 🕗 Version & Regression Information Tested with v4.3.4 ⏯ Pla...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/44700
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: Functional properties make inference non-working in case of circular type parameter constraints like T extends M\u003cT>","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\nCircular type parameter constraint, inference change due to presence of functional property\r\nRelated: #40439 \r\n\r\n### 🕗 Version & Regression Information\r\n\r\nTested with v4.3.4\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground](https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEYD2A7AzgF3gWwFzwB4AVeEADwxBWDXgFliA+RgCj3iIEp4BeRjgFACMATwAOCBgGUQEAGYAaeADVe8AAowkYgjPlKARADcDzXgPjwA3vCP5lF+EowB+fCzsrufW0gCWwI4AvkKiEhpaOkRKANL8PPAxpBRUNPAA1iAiSHIc8C4cANoxALrw+AYgMFowBkIA9PXJEmCUwOX0BDaeKACu2ABGVc5u8B74fYNV3vxG-u1BjAKN8FCtvVAQlh0MvSjpKEgA7ihL2CxWjp4AjAqOGPjpvPxWIUGcDU3kLW07XbYTfpDGDwRbLJprDAbLaWfAMbqAqYgsHnS6WG4Cd5AA)\r\n\r\n### 💻 Code\r\n\r\n```ts\r\ndeclare const m: \u003cT extends M\u003cT>>(m: T) => T\r\n\r\ntype M\u003cSelf, V = Prop\u003cSelf, \"v\">> =\r\n { v: V\r\n , t?: (v: V) => void\r\n }\r\n\r\ntype Prop\u003cT, K> = K extends keyof T ? T[K] : \"error\"\r\n\r\n// expected : M\u003c{ v: number, t?: (v: number) => void }>\r\n// actual : M\u003cunknown>\r\nm({\r\n v: 1,\r\n t: k => {}\r\n})\r\n\r\n// expected : M\u003c{ v: number }>\r\n// actual : M\u003c{ v: number }>\r\nm({\r\n v: 1\r\n})\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nIn first function call of `m`, the parameter is inferred as `M\u003cunknown>` in other words the TypeScript couldn't infer anything.\r\n\r\n### 🙂 Expected behavior\r\n\r\nIn first function call of `m`, the parameter should be inferred as `M\u003c{ v: number, t?: (v: number) => void }>`. Especially given that removal of `t` works as seen in the second function call. Presence of a functional property shouldn't make the inference completely non-working.\r\n","author":{"url":"https://github.com/devanshj","@type":"Person","name":"devanshj"},"datePublished":"2021-06-22T19:43:37Z","url":"https://github.com/microsoft/TypeScript/issues/44700"}
| 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:0191f156-a69b-2e04-bffd-8b30317f81d4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE44:14700E:FB616A:13FB043:6B010EF5 |
| html-safe-nonce | f3431e54248c6ad3e71920ae4e27198eca4d8dff1cdeaa4ab3cc2473b16a2f38 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTQ0OjE0NzAwRTpGQjYxNkE6MTNGQjA0Mzo2QjAxMEVGNSIsInZpc2l0b3JfaWQiOiI1NDk2NTQ4MzcyMzg5MTA1Mzk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d176f36ee333023e01a69f535a524598ae478de24070c424132e3a0d55a3b884 |
| hovercard-subject-tag | issue:927575386 |
| 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/44700/issue_layout |
| twitter:image | https://opengraph.githubassets.com/292043957f63a95bb1e2d9e8b78ef8e35ddb2da77f7df36e59944c2b8ebb238b/microsoft/TypeScript/issues/44700 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/292043957f63a95bb1e2d9e8b78ef8e35ddb2da77f7df36e59944c2b8ebb238b/microsoft/TypeScript/issues/44700 |
| og:image:alt | Bug Report 🔎 Search Terms Circular type parameter constraint, inference change due to presence of functional property Related: #40439 🕗 Version & Regression Information Tested with v4.3.4 ⏯ Playgro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devanshj |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width