René's URL Explorer Experiment


Title: Generic function argument lost when passed to a generic identity function · Issue #38007 · microsoft/TypeScript · GitHub

Open Graph Title: Generic function argument lost when passed to a generic identity function · Issue #38007 · microsoft/TypeScript

X Title: Generic function argument lost when passed to a generic identity function · Issue #38007 · microsoft/TypeScript

Description: TypeScript Version: 3.8.3 Search Terms: generic function "instantiated with a different subtype of constraint" Expected behavior: In TypeScript 3.7.5, the function returned by define is of type (argument: E, somethingElse: { key: E; }...

Open Graph Description: TypeScript Version: 3.8.3 Search Terms: generic function "instantiated with a different subtype of constraint" Expected behavior: In TypeScript 3.7.5, the function returned by define is of type ...

X Description: TypeScript Version: 3.8.3 Search Terms: generic function "instantiated with a different subtype of constraint" Expected behavior: In TypeScript 3.7.5, the function returned by define is o...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic function argument lost when passed to a generic identity function","articleBody":"**TypeScript Version:**  3.8.3\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\n* generic function\r\n* \"instantiated with a different subtype of constraint\"\r\n\r\n**Expected behavior:**\r\nIn TypeScript 3.7.5, the function returned by `define` is of type `\u003cE>(argument: E, somethingElse: { key: E; }) => (a: string) => number`.\r\n\r\n**Actual behavior:**\r\nIn TypeScript 3.8.3, the function returned by `define` is of type `(argument: E, somethingElse: { key: E; }) => (a: string) => number`.\r\n\r\nI believe this behavior is a regression, since a function with generic argument types without itself being generic doesn't really make sense, and the coded did work with TS 3.7. My assumption here is that TS doesn't understand the two `E`s actually _must_ be the same type.\r\n\r\n**Code**\r\n```ts\r\n// In reality there are more arguments of an Action and they have complex types\r\ntype Action\u003cR> = (a: string) => R;\r\n\r\n// The purpose of this method is to allow definitions of action creators without explicitly typing an\r\n// Action's argument types every time\r\nfunction define\u003cC extends (...args: any[]) => Action\u003cany>>(creator: C): C {\r\n    return creator;\r\n}\r\n\r\n// Type inferred in TS 3.7.5: \u003cE>(argument: E, somethingElse: { key: E; }) => (a: string) => number\r\n// Type inferred in TS 3.8.3: (argument: E, somethingElse: { key: E; }) => (a: string) => number\r\nconst definedAction = define(\r\n    \u003cE>(\r\n        argument: E,\r\n        somethingElse: { key: E }\r\n    ) => (a /* a has a properly inferred type */) => 5,\r\n);\r\n\r\nconst extra = { test: \"\" };\r\n\r\ndefinedAction(extra, { key: extra });\r\n/*\r\nError only in TS 3.8.3:\r\nArgument of type '{ test: string; }' is not assignable to parameter of type 'E'.\r\n  '{ test: string; }' is assignable to the constraint of type 'E', but 'E' could be instantiated with a different subtype of constraint '{}'.(2345)\r\n*/\r\n\r\n```\r\n\r\n\r\n\r\n\u003cdetails>\u003csummary>\u003cb>Output\u003c/b>\u003c/summary>\r\n\r\n```ts\r\n\"use strict\";\r\n// The purpose of this method is to allow definitions of action creators without explicitly typing an\r\n// Action's argument types every time\r\nfunction define(creator) {\r\n    return creator;\r\n}\r\n// Type inferred in TS 3.7.5: \u003cE>(argument: E, somethingElse: { key: E; }) => (a: string) => number\r\n// Type inferred in TS 3.8.3: (argument: E, somethingElse: { key: E; }) => (a: string) => number\r\nconst definedAction = define((argument, somethingElse) => (a /* a has a properly inferred type */) => 5);\r\nconst extra = { test: \"\" };\r\ndefinedAction(extra, { key: extra });\r\n/*\r\nError only in TS 3.8.3:\r\nArgument of type '{ test: string; }' is not assignable to parameter of type 'E'.\r\n  '{ test: string; }' is assignable to the constraint of type 'E', but 'E' could be instantiated with a different subtype of constraint '{}'.(2345)\r\n*/\r\n\r\n```\r\n\r\n\r\n\u003c/details>\r\n\r\n\r\n\u003cdetails>\u003csummary>\u003cb>Compiler Options\u003c/b>\u003c/summary>\r\n\r\n```json\r\n{\r\n  \"compilerOptions\": {\r\n    \"noImplicitAny\": true,\r\n    \"strictNullChecks\": true,\r\n    \"strictFunctionTypes\": true,\r\n    \"strictPropertyInitialization\": true,\r\n    \"strictBindCallApply\": true,\r\n    \"noImplicitThis\": true,\r\n    \"noImplicitReturns\": true,\r\n    \"useDefineForClassFields\": false,\r\n    \"alwaysStrict\": true,\r\n    \"allowUnreachableCode\": false,\r\n    \"allowUnusedLabels\": false,\r\n    \"downlevelIteration\": false,\r\n    \"noEmitHelpers\": false,\r\n    \"noLib\": false,\r\n    \"noStrictGenericChecks\": false,\r\n    \"noUnusedLocals\": false,\r\n    \"noUnusedParameters\": false,\r\n    \"esModuleInterop\": true,\r\n    \"preserveConstEnums\": false,\r\n    \"removeComments\": false,\r\n    \"skipLibCheck\": false,\r\n    \"checkJs\": false,\r\n    \"allowJs\": false,\r\n    \"declaration\": true,\r\n    \"experimentalDecorators\": false,\r\n    \"emitDecoratorMetadata\": false,\r\n    \"target\": \"ES2017\",\r\n    \"module\": \"ESNext\"\r\n  }\r\n}\r\n```\r\n\r\n\r\n\u003c/details>\r\n\r\n**Playground Link:** [Provided](https://www.typescriptlang.org/play/index.html?ssl=1&ssc=1&pln=27&pc=1#code/PTAEEkDtQJwUwIYBsCWAXAnqNALO9QECBbAewKIHMBXYuSNAZ1FIDNDoBBAYzRVOgJIAE2x4sOBADc4obqWIAHJHAAe2DIriMAUJi2gefAQB4ASgD5QAXlAAKBAC5QjNDBSRKAShtWzAbh0dEFAAFTxQRWoYRVJGWTYxFGY6XFJRZOxSQiQkUgB3UGE4Vg90fkhmRIReCrl4BDRyZnz0HFJqNFA1ZRRudCQsfQ9KDmCwIwqAcmYqWnou-W1umRghlDodVmpIWoEiko84EwBhbtU0emFmOwA6e6pGZyEMAG0AXR9rK0nTF4sLHZuA0mjBnCcvODQABvHSgeGwOBoaLQYGIUGBAC+QRCoU0sg8rHw8Ay0FCAGVQABmW4AdluAFZnCYAKKAuZ0BjOFkAGhcCiROBGLKQ8Wc0NAAGs4Bhuf5QJivlYHM5XO5PErQJBaAAjfDjML40CE4lwUlhSk0gActypzgcMBonLQ3L5jAFuGForg4qlMrlCs1KpcbhGmu1xD1MB08kqXWKpUgZt+0FsCaOdjhCNZgKzCIRHIWrrz+f5qSFnhFYphftloBZCpLQYQoGAACpCKBJLNIjBSFoYINjZAiTASRoDG3gJqGTydF5AjGBK5zm4W7YJZdXM4AEQ7hWL9NJ4QpuxqNd8iXSuvnmAtxWBds6Flj8gsSBDjwW6m3G12nScI68wMCw7BLKAUybtoLohuqlDypiUzGswkCkF0CCMIwKCUJACA6ioWSREQCCpPgoETrIUwslMtxZpB2DQaqoaeAhSGZBhWE4XhBFNGIsixmqCAeF0iTgVRUx8jqnQQdRcgdEgoh6sOrhCHwjRmqArS4J2wgoKwo4LC41A6uBiQCWuwkQdCiG3HYABMVIACwMl4OhTjoQA)\r\n\r\n**Related issues:**\r\n* #30134","author":{"url":"https://github.com/invliD","@type":"Person","name":"invliD"},"datePublished":"2020-04-16T15:31:45Z","url":"https://github.com/microsoft/TypeScript/issues/38007"}

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:1a334e0d-ffc7-fccf-5f74-5543e72a6e12
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBFA0:136CDA:9138F7:C0E0D0:6B01B4F7
html-safe-nonce6321cfbfb088c07139f7ad7b94295a7c0745ea2f5593b48ce5f1932fba7109a4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkEwOjEzNkNEQTo5MTM4Rjc6QzBFMEQwOjZCMDFCNEY3IiwidmlzaXRvcl9pZCI6IjI2OTQzMjAyMTMwNjY4ODg0MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2798864f0e5096ccbd848460ed6c0f74be2ec0cc217ccf348c42f81a413527b2
hovercard-subject-tagissue:601169474
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/38007/issue_layout
twitter:imagehttps://opengraph.githubassets.com/046d726462d0d398d7490e995c1ed1fb295b5976c7da85263ff4497bba80d083/microsoft/TypeScript/issues/38007
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/046d726462d0d398d7490e995c1ed1fb295b5976c7da85263ff4497bba80d083/microsoft/TypeScript/issues/38007
og:image:altTypeScript Version: 3.8.3 Search Terms: generic function "instantiated with a different subtype of constraint" Expected behavior: In TypeScript 3.7.5, the function returned by define is of type ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameinvliD
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/38007#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F38007
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%2F38007
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/38007
Reloadhttps://github.com/microsoft/TypeScript/issues/38007
Reloadhttps://github.com/microsoft/TypeScript/issues/38007
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/38007
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38007
Generic function argument lost when passed to a generic identity functionhttps://github.com/microsoft/TypeScript/issues/38007#top
https://github.com/ahejlsberg
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
https://github.com/invliD
Sebastian Brückner (invliD)https://github.com/invliD
on Apr 16, 2020https://github.com/microsoft/TypeScript/issues/38007#issue-601169474
Providedhttps://www.typescriptlang.org/play/index.html?ssl=1&ssc=1&pln=27&pc=1#code/PTAEEkDtQJwUwIYBsCWAXAnqNALO9QECBbAewKIHMBXYuSNAZ1FIDNDoBBAYzRVOgJIAE2x4sOBADc4obqWIAHJHAAe2DIriMAUJi2gefAQB4ASgD5QAXlAAKBAC5QjNDBSRKAShtWzAbh0dEFAAFTxQRWoYRVJGWTYxFGY6XFJRZOxSQiQkUgB3UGE4Vg90fkhmRIReCrl4BDRyZnz0HFJqNFA1ZRRudCQsfQ9KDmCwIwqAcmYqWnou-W1umRghlDodVmpIWoEiko84EwBhbtU0emFmOwA6e6pGZyEMAG0AXR9rK0nTF4sLHZuA0mjBnCcvODQABvHSgeGwOBoaLQYGIUGBAC+QRCoU0sg8rHw8Ay0FCAGVQABmW4AdluAFZnCYAKKAuZ0BjOFkAGhcCiROBGLKQ8Wc0NAAGs4Bhuf5QJivlYHM5XO5PErQJBaAAjfDjML40CE4lwUlhSk0gActypzgcMBonLQ3L5jAFuGForg4qlMrlCs1KpcbhGmu1xD1MB08kqXWKpUgZt+0FsCaOdjhCNZgKzCIRHIWrrz+f5qSFnhFYphftloBZCpLQYQoGAACpCKBJLNIjBSFoYINjZAiTASRoDG3gJqGTydF5AjGBK5zm4W7YJZdXM4AEQ7hWL9NJ4QpuxqNd8iXSuvnmAtxWBds6Flj8gsSBDjwW6m3G12nScI68wMCw7BLKAUybtoLohuqlDypiUzGswkCkF0CCMIwKCUJACA6ioWSREQCCpPgoETrIUwslMtxZpB2DQaqoaeAhSGZBhWE4XhBFNGIsixmqCAeF0iTgVRUx8jqnQQdRcgdEgoh6sOrhCHwjRmqArS4J2wgoKwo4LC41A6uBiQCWuwkQdCiG3HYABMVIACwMl4OhTjoQA
Meta-issue: Use Full Unification for Generic Inference? #30134https://github.com/microsoft/TypeScript/issues/30134
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Apr 17, 2020https://github.com/microsoft/TypeScript/issues/38007#event-3245240707
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 Apr 17, 2020https://github.com/microsoft/TypeScript/issues/38007#event-3245240839
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.0https://github.com/microsoft/TypeScript/milestone/114
on Apr 17, 2020https://github.com/microsoft/TypeScript/issues/38007#event-3245241141
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Apr 17, 2020https://github.com/microsoft/TypeScript/issues/38007#issuecomment-615367445
#37110https://github.com/microsoft/TypeScript/issues/37110
#37811https://github.com/microsoft/TypeScript/pull/37811
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
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 Apr 17, 2020https://github.com/microsoft/TypeScript/issues/38007#event-3245303038
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Apr 17, 2020https://github.com/microsoft/TypeScript/issues/38007#event-3245303750
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
TypeScript 4.0https://github.com/microsoft/TypeScript/milestone/114
on Apr 17, 2020https://github.com/microsoft/TypeScript/issues/38007#event-3245304685
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/38007#event-20416939421
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/38007
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38007
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
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.