René's URL Explorer Experiment


Title: Add type operators that can answer "given function type T, what is the type of its return value when arguments P are passed in?" · Issue #40179 · microsoft/TypeScript · GitHub

Open Graph Title: Add type operators that can answer "given function type T, what is the type of its return value when arguments P are passed in?" · Issue #40179 · microsoft/TypeScript

X Title: Add type operators that can answer "given function type T, what is the type of its return value when arguments P are passed in?" · Issue #40179 · microsoft/TypeScript

Description: Search Terms overload infer function operator arguments parameters return Suggestion // Already possible type ValueForKey = T[K]; // Proposal type Callable = (...args: any[]) => any; type ValueForArguments

Open Graph Description: Search Terms overload infer function operator arguments parameters return Suggestion // Already possible type ValueForKey = T[K]; // Proposal type Callable = (...args: any[]) ...

X Description: Search Terms overload infer function operator arguments parameters return Suggestion // Already possible type ValueForKey<T, K extends keyof T> = T[K]; // Proposal type Callable = (...args: a...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add type operators that can answer \"given function type T, what is the type of its return value when arguments P are passed in?\"","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n  * Read the FAQ, especially the \"Common Feature Requests\" section: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\n--\u003e\r\n\r\n## Search Terms\r\n\r\n\u003c!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily --\u003e\r\noverload infer function operator arguments parameters return\r\n\r\n## Suggestion\r\n\r\n```ts\r\n// Already possible\r\ntype ValueForKey\u003cT, K extends keyof T\u003e = T[K];\r\n\r\n// Proposal\r\ntype Callable = (...args: any[]) =\u003e any;\r\ntype ValueForArguments\u003cT extends Callable, A extends paramsof T\u003e = T(...A);\r\n```\r\n\r\n## Use Cases\r\n\r\nThis is a proposal that would help with overloaded function issues like #26591 and would help my [type testing library](https://humeris.org/espresso-shot) be able to support checks like `expectTypeOf(fn).toBeCallableWith(args)`.\r\n\r\nNote that though `ValueForKey` could be implemented as:\r\n```ts\r\ntype ValueForKey\u003cT, K extends keyof T\u003e = \r\n  T extends {[Key in K]: infer U} ? U : never;\r\n```\r\nThe following will only work for non-overloaded functions:\r\n```ts\r\ntype ValueForArguments\u003cT extends Callable, P extends Parameters\u003cT\u003e\u003e = \r\n  T extends (...args: P) =\u003e infer R ? R : never;\r\n```\r\nsince both the inference from `Parameters\u003cT\u003e` and the type definition will only consider one of the overloads.\r\n\r\nWhat I'm asking is not for inference to consider multiple overloads, which would be nice but might complexify the implementation of type inference, but direct support for `paramsof` and `T(A1, A2, ...A)` type syntax which behaves correctly with overloaded functions.\r\n\r\n## Examples\r\n```ts\r\ninterface OverloadedFunction {\r\n  (arg: number): number;\r\n  (arg: string): string;\r\n}\r\n\r\n// `number`\r\ntype Result1 = OverloadedFunction(number);\r\n\r\n// `number | string`\r\ntype Result2 = OverloadedFunction(number | string);\r\n\r\n// `[number] | [string]`\r\ntype Result3 = paramsof OverloadedFunction;\r\n\r\n// `number | string`\r\ntype Result4 = OverloadedFunction(...paramsof OverloadedFunction)\r\n```\r\n\r\n\u003c!--\r\nWhat do you want to use this for?\r\nWhat shortcomings exist with current approaches?\r\n--\u003e\r\n\r\n\r\n\r\n\u003c!-- Show how this would be used and what the behavior would be --\u003e\r\n\r\n## Also\r\nGiven the above, it would also make sense to have something like\r\n```ts\r\ntype Newable = new (...args: any[]) =\u003e any;\r\ntype ValueForArguments\u003cT extends Newable, A extends paramsof new T\u003e = new T(...A);\r\n```\r\nwhere `new T` takes the constructor type of `T` and turns it into a function type\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n","author":{"url":"https://github.com/lazytype","@type":"Person","name":"lazytype"},"datePublished":"2020-08-21T11:46:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/40179/TypeScript/issues/40179"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0ce128d2-4c4e-13a0-5389-80660dc81954
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idED54:C1BD7:6EFBA0:9D05D4:6A6306DE
html-safe-nonce177b0decfb32a3c60a622f43b3709fee9296613ff93a8c39a898c0dce56e0615
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDU0OkMxQkQ3OjZFRkJBMDo5RDA1RDQ6NkE2MzA2REUiLCJ2aXNpdG9yX2lkIjoiODg4NDI2NTI0MDgzNjExNDE0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacaf7bd1b6ed82385db02e040b94f8b30b171241c1bf54a3eb78d2794c34ef21f2
hovercard-subject-tagissue:683503798
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/40179/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c094d11bac6f796b6ad07c072ac3577d0d3a8cf01d0a1bdc0765a237064bb32d/microsoft/TypeScript/issues/40179
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c094d11bac6f796b6ad07c072ac3577d0d3a8cf01d0a1bdc0765a237064bb32d/microsoft/TypeScript/issues/40179
og:image:altSearch Terms overload infer function operator arguments parameters return Suggestion // Already possible type ValueForKey = T[K]; // Proposal type Callable = (...args: any[]) ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelazytype
hostnamegithub.com
expected-hostnamegithub.com
Noneb48e7bf0b1945d51f303503b057abf666ce74c3efbe107b413db2bb921c3f012
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
release9370f37042c29822d6ba7e3f670f0036a0155b21
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/40179#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F40179
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F40179
Sign up https://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/40179
Reloadhttps://github.com/microsoft/TypeScript/issues/40179
Reloadhttps://github.com/microsoft/TypeScript/issues/40179
Please reload this pagehttps://github.com/microsoft/TypeScript/issues/40179
microsoft https://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Notifications https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Fork 13.6k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Star 110k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Code https://github.com/microsoft/TypeScript
Issues 5k+ https://github.com/microsoft/TypeScript/issues
Pull requests 21 https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality 0 https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Code https://github.com/microsoft/TypeScript
Issues https://github.com/microsoft/TypeScript/issues
Pull requests https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Add type operators that can answer "given function type T, what is the type of its return value when arguments P are passed in?"https://github.com/microsoft/TypeScript/issues/40179#top
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/lazytype
lazytypehttps://github.com/lazytype
on Aug 21, 2020https://github.com/microsoft/TypeScript/issues/40179#issue-683503798
#26591https://github.com/microsoft/TypeScript/issues/26591
type testing libraryhttps://humeris.org/espresso-shot
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%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.