René's URL Explorer Experiment


Title: Generic constraint generates a TS2344 · Issue #36852 · microsoft/TypeScript · GitHub

Open Graph Title: Generic constraint generates a TS2344 · Issue #36852 · microsoft/TypeScript

X Title: Generic constraint generates a TS2344 · Issue #36852 · microsoft/TypeScript

Description: TypeScript Version: 3.7.x, 3.8.1, 3.9.x (next) Search Terms: Generic constraint 2344 Code type KeyOf = keyof ((T extends any ? (k: T)=>void : never) extends ((k: infer I)=>void) ? I : never); type Constraint = KeyOf extends neve...

Open Graph Description: TypeScript Version: 3.7.x, 3.8.1, 3.9.x (next) Search Terms: Generic constraint 2344 Code type KeyOf = keyof ((T extends any ? (k: T)=>void : never) extends ((k: infer I)=>void) ? I : never); ty...

X Description: TypeScript Version: 3.7.x, 3.8.1, 3.9.x (next) Search Terms: Generic constraint 2344 Code type KeyOf<T> = keyof ((T extends any ? (k: T)=>void : never) extends ((k: infer I)=>void) ? I ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic constraint generates a TS2344 ","articleBody":"**TypeScript Version:**  3.7.x, 3.8.1, 3.9.x (next)\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** Generic constraint 2344 \r\n\r\n**Code**\r\n\r\n```ts\r\ntype KeyOf\u003cT> = keyof ((T extends any ? (k: T)=>void : never) extends ((k: infer I)=>void) ? I : never);\r\n\r\ntype Constraint\u003cT> = KeyOf\u003cT> extends never\r\n  ? any\r\n    // : KeyOf\u003cany> extends KeyOf\u003cT>\r\n    // ? any\r\n  : (\r\n    'a' extends KeyOf\u003cT>\r\n      ? never\r\n      : any\r\n    );\r\n\r\ntype ForceConstraint\u003cT> = T extends Constraint\u003cT> ? T : never;\r\n\r\ninterface Interface\u003cT extends Constraint\u003cT>> {\r\n  b: string;\r\n}\r\n\r\ntype Infer\u003cCB> = CB extends () => infer TReturn\r\n  ? ForceConstraint\u003cTReturn>\r\n  : never;\r\n\r\ntype InferWithConstraint\u003cCB> = ForceConstraint\u003cInfer\u003cCB>>;\r\n\r\ntype InferInterfaceFromCallback\u003cCB> = Interface\u003cInferWithConstraint\u003cCB>>; // invalid => NOT OK\r\ntype InferInterfaceFromCallback1\u003cCB> = Interface\u003cInfer\u003cCB>;> // invalid too => NOT OK\r\n\r\n// just debug purpose\r\ntype A1 = Interface\u003cunknown>;\r\ntype A2 = Interface\u003cany>; // invalid => OK\r\ntype A3 = Interface\u003cnever>;\r\ntype A4 = Interface\u003cundefined>;\r\ntype A5 = Interface\u003cnumber>;\r\ntype A6 = Interface\u003cstring>;\r\ntype A7 = Interface\u003cnull>;\r\ntype A8 = Interface\u003cobject>;\r\ntype A9 = Interface\u003c{}>;\r\ntype A_FAIL1 = Interface\u003c{ a: 'b' }>; // invalid => OK\r\ntype A_FAIL2 = Interface\u003c{ a: 'b' } | 1>; // invalid => OK\r\n```\r\n\r\n[Playground Link](http://www.typescriptlang.org/play/?ts=3.9.0-dev.20200215&ssl=38&ssc=54&pln=37&pc=1#)\r\n\r\n**Expected behavior:**\r\n```ts\r\ntype InferInterfaceFromCallback\u003cCB> = Interface\u003cInferWithConstraint\u003cCB>>;\r\n``` \r\nShould be valid\r\n\r\n**Explanation:**\r\n\r\nSo, i was trying to apply a specific constraint on a generic type. \r\n\r\n`Constraint\u003cT>` 'returns' never if T contains a property called ```a```, else it returns any\r\n\r\n`ForceConstraint\u003cT>` tries to help typescript to know if T is valid, else it returns never\r\n\r\n` Interface\u003cT extends Constraint\u003cT>>` forces its generic type to respect `Constraint`\r\n\r\n`Infer\u003cCB>` infers the return type of **CB** and ensures it follows `Constraint`\r\n\r\n`InferWithConstraint\u003cCB>` forces again `Infer\u003cCB>` to be compliant with `Constraint` (even if it is already)\r\n\r\nSo `Interface\u003cInferWithConstraint\u003cCB>>` should be valid, sadly, typescript reports:\r\n```\r\nTS2344: Type 'ForceConstraint\u003cInfer\u003cCB>>' does not satisfy the constraint 'Constraint\u003cForceConstraint\u003cInfer\u003cCB>>>'.\r\n```\r\n\r\n**Potentially related issues:**\r\n\r\n- https://github.com/microsoft/TypeScript/issues/31736\r\n- https://github.com/microsoft/TypeScript/issues/34604\r\n \r\n","author":{"url":"https://github.com/lifaon74","@type":"Person","name":"lifaon74"},"datePublished":"2020-02-18T13:24:55Z","url":"https://github.com/microsoft/TypeScript/issues/36852"}

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:70fdc2c6-a8a9-4c8c-9e90-47919a90170f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC2D0:157C65:26AB52A:339ABAB:6B01AD3C
html-safe-nonce0e6455adf83512af365de7b1e38e1896bea601f6aa72984bd1ccf352376ee212
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkQwOjE1N0M2NToyNkFCNTJBOjMzOUFCQUI6NkIwMUFEM0MiLCJ2aXNpdG9yX2lkIjoiMzE3NDA5MTk1NzIyODEyMTQwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4d27e8b0bd86e728233e4bf35223fb110cee9167bfe726ba6806f663ebde7183
hovercard-subject-tagissue:566890855
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/36852/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f812b23823613b07c9c171a63ae7619ef6313fb0c8f9271cf4169081711a70ac/microsoft/TypeScript/issues/36852
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f812b23823613b07c9c171a63ae7619ef6313fb0c8f9271cf4169081711a70ac/microsoft/TypeScript/issues/36852
og:image:altTypeScript Version: 3.7.x, 3.8.1, 3.9.x (next) Search Terms: Generic constraint 2344 Code type KeyOf = keyof ((T extends any ? (k: T)=>void : never) extends ((k: infer I)=>void) ? I : never); ty...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelifaon74
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/36852#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F36852
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%2F36852
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/36852
Reloadhttps://github.com/microsoft/TypeScript/issues/36852
Reloadhttps://github.com/microsoft/TypeScript/issues/36852
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)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/36852
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/36852
Generic constraint generates a TS2344 https://github.com/microsoft/TypeScript/issues/36852#top
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/lifaon74
valentin richard (lifaon74)https://github.com/lifaon74
on Feb 18, 2020https://github.com/microsoft/TypeScript/issues/36852#issue-566890855
Playground Linkhttp://www.typescriptlang.org/play/?ts=3.9.0-dev.20200215&ssl=38&ssc=54&pln=37&pc=1#
3.5.1 regression in mapped types on tuples #31736https://github.com/microsoft/TypeScript/issues/31736
Type inferred within a transitive constraint composition does not satisfy the constraint #34604https://github.com/microsoft/TypeScript/issues/34604
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on Feb 27, 2020https://github.com/microsoft/TypeScript/issues/36852#event-3079132530
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Backloghttps://github.com/microsoft/TypeScript/milestone/29
on Feb 27, 2020https://github.com/microsoft/TypeScript/issues/36852#event-3079132631
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/36852
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/36852
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
BacklogNo due datehttps://github.com/microsoft/TypeScript/milestone/29
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

Viewport: width=device-width


URLs of crawlers that visited me.