René's URL Explorer Experiment


Title: Constraint in generic type forgotten in assignability check · Issue #58370 · microsoft/TypeScript · GitHub

Open Graph Title: Constraint in generic type forgotten in assignability check · Issue #58370 · microsoft/TypeScript

X Title: Constraint in generic type forgotten in assignability check · Issue #58370 · microsoft/TypeScript

Description: 🔎 Search Terms generic type constraint not applied inside type 🕗 Version & Regression Information This changed in commit or PR #57871 ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5.4.5#code/C4TwDgpgBAggdiA0hEUC8U4FcC2AjCAJyg...

Open Graph Description: 🔎 Search Terms generic type constraint not applied inside type 🕗 Version & Regression Information This changed in commit or PR #57871 ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5.4.5...

X Description: 🔎 Search Terms generic type constraint not applied inside type 🕗 Version & Regression Information This changed in commit or PR #57871 ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/58370

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constraint in generic type forgotten in assignability check","articleBody":"### 🔎 Search Terms\r\n\r\ngeneric type constraint not applied inside type\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This changed in commit or PR #57871\r\n\r\n### ⏯ Playground Link\r\n\r\nhttps://www.typescriptlang.org/play/?ts=5.4.5#code/C4TwDgpgBAggdiA0hEUC8U4FcC2AjCAJygB8oBnYQgSzgHNSKR8B7AGwG4AoL0SKAEoRgWQnAAq4CMhAsAZgB4A8ngBWUCAA9gEOABNyUFmogBjYAD50UFeq079h46rPAuUD1AD8UANoBrFHkbNQBdDW1dAz84CAA3IlD3TxSfWITCZJSPAC4oAG8-GShaKEDZORD1AENDShp6UIBaLzyACgBKdCtigF9feto6JJS89KJuXikoGQBJOQBlajo4apFCCCU5W1cFLKqIh2jnVwAafeL7KMN4JBRzlKF1iSkZQwwn0RfIGXllNQs5ysH2EX0kPxQhiujignW6MxQ3lhbThaB6KC60OinzE4OkkKRxTG8SIXWJGUmWjALEIwCgfGgQj0WFMED0AEZ-nZIjCTuZTgjUFibggZAKAGrVNhYCAC2xvQ7XMpBSq2azlYK2YEXRHCwXzJYrNaiTbbEzmLkCmQWfapQWKmHygkAemdsDYAHdqiBDFQZQA6W3ZDw+Qq+RAlOCC0J5SXS6C9IPB8lEJNQFOESauqAAdRp-kM1EqphYcHq1VodOohg2TVMAAszIE9JHyNQ9NAGYGqTS6QzBGyWWyAExch3Hc3AK26nnRW5iqBxmVytQKvUa1VqdUqqralKXWciu4gNM+A9HQxzRbLVbrU07C22acgG3B4NnmcXqoK7MwT3e31CADNM31DIpI2jWMpRlKBEzfeCMxAzxEIQzASUzLggA\r\n\r\n### 💻 Code\r\n\r\n```ts\r\ntype AnyKey = number | string | symbol;\r\n\r\ntype ReturnTypeKeyof\u003cObj extends object> = Obj extends object\r\n    ? [keyof Obj] extends [never]\r\n        ? never\r\n        : { [Key in keyof Obj as string]-?: () => Key }[string]\r\n    : never;\r\n\r\ntype KeyIfSignatureOfObject\u003c\r\n    Obj extends object,\r\n    Key extends AnyKey,\r\n    ReturnTypeKeys = ReturnTypeKeyof\u003cObj>,\r\n> = ReturnTypeKeys extends () => Key ? ((() => Key) extends ReturnTypeKeys ? Key : never) : never;\r\n\r\nexport type Reduced\u003cObj extends object, Key extends AnyKey, Value, ObjKeys extends keyof Obj = keyof Obj> =\r\n    Key extends KeyIfSignatureOfObject\u003cObj, Key>\r\n        ? Key extends ObjKeys // Always true.\r\n            ? { [K in Key]: Value }\r\n            : never\r\n        : never;\r\n```\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\nGives error `Type 'ObjKeys & KeyIfSignatureOfObject\u003cObj, Key, ReturnTypeKeyof\u003cObj>> & Key' is not assignable to type 'string | number | symbol'.`\r\n\r\n### 🙂 Expected behavior\r\n\r\nNo error; `Key` was constrained to `AnyKey` and should be usable as a key.\r\n\r\n### Additional information about the issue\r\n\r\nI reduced this from a much larger example, so the code here doesn't make much sense (the names of the helper types might also not make sense anymore). It might be possible to reduce it further but I wasn't able to find anything obvious.\r\n\r\nAs the playground shows, simply wrapping the body of the type with a `Key extends AnyKey` check makes the error go away, which makes me think that this must be a bug (I guess it distributes the union, but the entire union should be valid as a key type). Checking `Key extends ObjKeys` *before* `KeyIfSignatureOfObject` also makes the error go away.","author":{"url":"https://github.com/ehoogeveen-medweb","@type":"Person","name":"ehoogeveen-medweb"},"datePublished":"2024-04-30T11:21:38Z","url":"https://github.com/microsoft/TypeScript/issues/58370"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8c5eb3fb-30e0-29cf-fdbf-2b57d4f1d643
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB1C2:198B2:42F2C5:592C9D:6B04F3D7
html-safe-nonceb2b0a457f560c853d5b570d8abc947a19137f9ba87b77cf9fbf277847efe13fd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUMyOjE5OEIyOjQyRjJDNTo1OTJDOUQ6NkIwNEYzRDciLCJ2aXNpdG9yX2lkIjoiODI3OTMzOTE2NzU4NzMwMDMxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6cfbd244a26e8519b210fc21030160ba6a4eb11019b7ccfaf1aaf04dc0deb4a0
hovercard-subject-tagissue:2271190661
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/58370/issue_layout
twitter:imagehttps://opengraph.githubassets.com/800fe08f03504525f4d90b73a90ef61ba68012e654caaf73d15865d383d14598/microsoft/TypeScript/issues/58370
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/800fe08f03504525f4d90b73a90ef61ba68012e654caaf73d15865d383d14598/microsoft/TypeScript/issues/58370
og:image:alt🔎 Search Terms generic type constraint not applied inside type 🕗 Version & Regression Information This changed in commit or PR #57871 ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5.4.5...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameehoogeveen-medweb
hostnamegithub.com
expected-hostnamegithub.com
Nonec0ff704de2671f716381d0ef36115cddb81606dd5397a5b003230bb8c02d623b
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbe60d43d23e17438879ed212ad20068394651c4
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/58370#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F58370
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F58370
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/58370
Reloadhttps://github.com/microsoft/TypeScript/issues/58370
Reloadhttps://github.com/microsoft/TypeScript/issues/58370
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests319 (319)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/58370
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/58370
#58403https://github.com/microsoft/TypeScript/pull/58403
Constraint in generic type forgotten in assignability checkhttps://github.com/microsoft/TypeScript/issues/58370#top
#58403https://github.com/microsoft/TypeScript/pull/58403
https://github.com/ahejlsberg
Bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix Availablehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
TypeScript 5.5.1https://github.com/microsoft/TypeScript/milestone/202
https://github.com/ehoogeveen-medweb
Emanuel Hoogeveen (ehoogeveen-medweb)https://github.com/ehoogeveen-medweb
on Apr 30, 2024https://github.com/microsoft/TypeScript/issues/58370#issue-2271190661
Divide-and-conquer strategy for intersections of unions #57871https://github.com/microsoft/TypeScript/pull/57871
https://www.typescriptlang.org/play/?ts=5.4.5#code/C4TwDgpgBAggdiA0hEUC8U4FcC2AjCAJygB8oBnYQgSzgHNSKR8B7AGwG4AoL0SKAEoRgWQnAAq4CMhAsAZgB4A8ngBWUCAA9gEOABNyUFmogBjYAD50UFeq079h46rPAuUD1AD8UANoBrFHkbNQBdDW1dAz84CAA3IlD3TxSfWITCZJSPAC4oAG8-GShaKEDZORD1AENDShp6UIBaLzyACgBKdCtigF9feto6JJS89KJuXikoGQBJOQBlajo4apFCCCU5W1cFLKqIh2jnVwAafeL7KMN4JBRzlKF1iSkZQwwn0RfIGXllNQs5ysH2EX0kPxQhiujignW6MxQ3lhbThaB6KC60OinzE4OkkKRxTG8SIXWJGUmWjALEIwCgfGgQj0WFMED0AEZ-nZIjCTuZTgjUFibggZAKAGrVNhYCAC2xvQ7XMpBSq2azlYK2YEXRHCwXzJYrNaiTbbEzmLkCmQWfapQWKmHygkAemdsDYAHdqiBDFQZQA6W3ZDw+Qq+RAlOCC0J5SXS6C9IPB8lEJNQFOESauqAAdRp-kM1EqphYcHq1VodOohg2TVMAAszIE9JHyNQ9NAGYGqTS6QzBGyWWyAExch3Hc3AK26nnRW5iqBxmVytQKvUa1VqdUqqralKXWciu4gNM+A9HQxzRbLVbrU07C22acgG3B4NnmcXqoK7MwT3e31CADNM31DIpI2jWMpRlKBEzfeCMxAzxEIQzASUzLggAhttps://www.typescriptlang.org/play/?ts=5.4.5#code/C4TwDgpgBAggdiA0hEUC8U4FcC2AjCAJygB8oBnYQgSzgHNSKR8B7AGwG4AoL0SKAEoRgWQnAAq4CMhAsAZgB4A8ngBWUCAA9gEOABNyUFmogBjYAD50UFeq079h46rPAuUD1AD8UANoBrFHkbNQBdDW1dAz84CAA3IlD3TxSfWITCZJSPAC4oAG8-GShaKEDZORD1AENDShp6UIBaLzyACgBKdCtigF9feto6JJS89KJuXikoGQBJOQBlajo4apFCCCU5W1cFLKqIh2jnVwAafeL7KMN4JBRzlKF1iSkZQwwn0RfIGXllNQs5ysH2EX0kPxQhiujignW6MxQ3lhbThaB6KC60OinzE4OkkKRxTG8SIXWJGUmWjALEIwCgfGgQj0WFMED0AEZ-nZIjCTuZTgjUFibggZAKAGrVNhYCAC2xvQ7XMpBSq2azlYK2YEXRHCwXzJYrNaiTbbEzmLkCmQWfapQWKmHygkAemdsDYAHdqiBDFQZQA6W3ZDw+Qq+RAlOCC0J5SXS6C9IPB8lEJNQFOESauqAAdRp-kM1EqphYcHq1VodOohg2TVMAAszIE9JHyNQ9NAGYGqTS6QzBGyWWyAExch3Hc3AK26nnRW5iqBxmVytQKvUa1VqdUqqralKXWciu4gNM+A9HQxzRbLVbrU07C22acgG3B4NnmcXqoK7MwT3e31CADNM31DIpI2jWMpRlKBEzfeCMxAzxEIQzASUzLggA
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs Investigationhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on May 1, 2024https://github.com/microsoft/TypeScript/issues/58370#event-12675367586
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on May 1, 2024https://github.com/microsoft/TypeScript/issues/58370#event-12675368042
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on May 2, 2024https://github.com/microsoft/TypeScript/issues/58370#issuecomment-2090828556
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on May 2, 2024https://github.com/microsoft/TypeScript/issues/58370#issuecomment-2090839145
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
Bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Needs Investigationhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on May 2, 2024https://github.com/microsoft/TypeScript/issues/58370#event-12685316584
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
TypeScript 5.5.1https://github.com/microsoft/TypeScript/milestone/202
on May 2, 2024https://github.com/microsoft/TypeScript/issues/58370#event-12685318324
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
Fix Availablehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
on May 2, 2024https://github.com/microsoft/TypeScript/issues/58370#event-12685672407
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#58403https://github.com/microsoft/TypeScript/pull/58403
on May 2, 2024https://github.com/microsoft/TypeScript/issues/58370#event-12690478635
microsofthttps://github.com/microsoft
on Oct 22, 2025https://github.com/microsoft/TypeScript/issues/58370#event-20419656799
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/58370
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/58370
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
Bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix Availablehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
TypeScript 5.5.1https://github.com/microsoft/TypeScript/milestone/202
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.