René's URL Explorer Experiment


Title: Type Inference on function arguments · Issue #15114 · microsoft/TypeScript · GitHub

Open Graph Title: Type Inference on function arguments · Issue #15114 · microsoft/TypeScript

X Title: Type Inference on function arguments · Issue #15114 · microsoft/TypeScript

Description: TypeScript Version: 2.3.0 Code function f(x: number){ return x; } function g(x){ return x}; function h(x){ return f(x); }; Expected behavior: I would expect the inferred type of g to be (x:any)=>any, and the infered type of h to be (x:nu...

Open Graph Description: TypeScript Version: 2.3.0 Code function f(x: number){ return x; } function g(x){ return x}; function h(x){ return f(x); }; Expected behavior: I would expect the inferred type of g to be (x:any)=>an...

X Description: TypeScript Version: 2.3.0 Code function f(x: number){ return x; } function g(x){ return x}; function h(x){ return f(x); }; Expected behavior: I would expect the inferred type of g to be (x:any)=>...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type Inference on function arguments","articleBody":"**TypeScript Version:**  \r\n2.3.0 \r\n\r\n**Code**\r\n\r\n```ts\r\nfunction f(x: number){\r\n   return x;\r\n}\r\n\r\nfunction g(x){ return x};\r\n\r\nfunction h(x){ return f(x); };\r\n```\r\n\r\n**Expected behavior:**\r\nI would expect the inferred type of `g` to be `(x:any)=>any`, and the infered type of `h` to be `(x:number) => number` (due to the restrictions placed by the call of `f`)\r\n\r\nWhen compiling with `noImplicitAny`, I would only expect an error on `g`, not on `h`\r\n\r\n**Actual behavior:**\r\nRunning `tsc --declaration` on this snippet gives me:\r\n\r\n```ts\r\ndeclare function f(x: number): number;\r\ndeclare function g(x: any): any;\r\ndeclare function h(x: any): number;\r\n```\r\n\r\nthe `x` argument on `h` does not seem to use the `f(x)` call to tighten the definition. \r\n\r\nConsidering the simplicity of the example, I imagine I might be missing an important detail in the type system that makes this the proper inference result, but I haven't figured it out yet.\r\n\r\n","author":{"url":"https://github.com/rtpg","@type":"Person","name":"rtpg"},"datePublished":"2017-04-11T01:51:41Z","url":"https://github.com/microsoft/TypeScript/issues/15114"}

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:9b9a679a-aa6c-f704-e109-e8ff9f751e03
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id96F4:1D86C4:836FFC:A878C7:6B00E8DA
html-safe-noncecadc0599cb6b750e82187f880def25b13e089c1c055b421e62f702ed719bbc28
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkY0OjFEODZDNDo4MzZGRkM6QTg3OEM3OjZCMDBFOERBIiwidmlzaXRvcl9pZCI6IjM1MTU3MDE1OTAzNjU5MDI5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacaacdcbf2d289bac67012cfb52fe94a9d24cadc93b1758e027c77f15ec74fcc34
hovercard-subject-tagissue:220817118
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/15114/issue_layout
twitter:imagehttps://opengraph.githubassets.com/397c337da5d43ace16aaf67151a234bc956b6311b60cab8543e6c72c23ca52ff/microsoft/TypeScript/issues/15114
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/397c337da5d43ace16aaf67151a234bc956b6311b60cab8543e6c72c23ca52ff/microsoft/TypeScript/issues/15114
og:image:altTypeScript Version: 2.3.0 Code function f(x: number){ return x; } function g(x){ return x}; function h(x){ return f(x); }; Expected behavior: I would expect the inferred type of g to be (x:any)=>an...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamertpg
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
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
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/15114#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F15114
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%2F15114
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/15114
Reloadhttps://github.com/microsoft/TypeScript/issues/15114
Reloadhttps://github.com/microsoft/TypeScript/issues/15114
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests308 (308)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/15114
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/15114
Type Inference on function argumentshttps://github.com/microsoft/TypeScript/issues/15114#top
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
https://github.com/rtpg
Raphael Gaschignard (rtpg)https://github.com/rtpg
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issue-220817118
https://github.com/vkurchatkin
Vladimir Kurchatkin (vkurchatkin)https://github.com/vkurchatkin
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293133377
https://github.com/rtpg
Raphael Gaschignard (rtpg)https://github.com/rtpg
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293156017
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293393165
https://github.com/bcherny
Boris Cherny (bcherny)https://github.com/bcherny
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293394416
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
Raphael Gaschignard (@rtpg)https://github.com/rtpg
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293398704
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.mdhttps://github.com/Microsoft/TypeScript/blob/master/doc/spec.md
https://github.com/bcherny
Boris Cherny (bcherny)https://github.com/bcherny
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293400553
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293415353
https://github.com/bcherny
Boris Cherny (bcherny)https://github.com/bcherny
on Apr 11, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293432294
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
this SO posthttp://stackoverflow.com/a/7244002/435124
https://github.com/rtpg
Raphael Gaschignard (rtpg)https://github.com/rtpg
on Apr 12, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-293443681
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/aluanhaddad
Aluan Haddad (aluanhaddad)https://github.com/aluanhaddad
on Apr 14, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-294229867
https://github.com/bcherny
Boris Cherny (bcherny)https://github.com/bcherny
on Apr 14, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-294232868
Aluan Haddad (@aluanhaddad)https://github.com/aluanhaddad
https://github.com/vkurchatkin
Vladimir Kurchatkin (vkurchatkin)https://github.com/vkurchatkin
on Apr 14, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-294235085
Boris Cherny (@bcherny)https://github.com/bcherny
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Apr 27, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-297851870
#15196https://github.com/microsoft/TypeScript/issues/15196
#1265https://github.com/microsoft/TypeScript/issues/1265
#15114https://github.com/microsoft/TypeScript/issues/15114
#11440https://github.com/microsoft/TypeScript/issues/11440
#15196 (comment)https://github.com/microsoft/TypeScript/issues/15196#issuecomment-294618460
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Apr 27, 2017https://github.com/microsoft/TypeScript/issues/15114#event-1061246533
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
on Apr 27, 2017https://github.com/microsoft/TypeScript/issues/15114#event-1061246645
https://github.com/rtpg
Raphael Gaschignard (rtpg)https://github.com/rtpg
on Apr 28, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-297886319
Mohamed Hegazy (@mhegazy)https://github.com/mhegazy
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Apr 28, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-298100733
Raphael Gaschignard (@rtpg)https://github.com/rtpg
https://github.com/joewood
Joe Wood (joewood)https://github.com/joewood
on Jun 7, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-306947548
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jun 8, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-307201572
Joe Wood (@joewood)https://github.com/joewood
COMEFROMhttps://en.wikipedia.org/wiki/COMEFROM
https://github.com/joewood
Joe Wood (joewood)https://github.com/joewood
on Jun 9, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-307369168
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/bcherny
Boris Cherny (bcherny)https://github.com/bcherny
on Jun 9, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-307413508
existential typeshttps://flow.org/en/docs/types/utilities/#toc-the-existential-type
https://github.com/vkurchatkin
Vladimir Kurchatkin (vkurchatkin)https://github.com/vkurchatkin
on Jun 9, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-307444716
https://github.com/bcherny
Boris Cherny (bcherny)https://github.com/bcherny
on Jun 9, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-307445094
Vladimir Kurchatkin (@vkurchatkin)https://github.com/vkurchatkin
https://github.com/vkurchatkin
Vladimir Kurchatkin (vkurchatkin)https://github.com/vkurchatkin
on Jun 9, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-307445822
Boris Cherny (@bcherny)https://github.com/bcherny
https://github.com/masaeedu
Asad Saeeduddin (masaeedu)https://github.com/masaeedu
on Jul 28, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-318728031
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
#14107 (comment)https://github.com/microsoft/TypeScript/issues/14107#issuecomment-296265761
https://github.com/masaeedu
Asad Saeeduddin (masaeedu)https://github.com/masaeedu
on Jul 28, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-318733710
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/masaeedu
Asad Saeeduddin (masaeedu)https://github.com/masaeedu
on Jul 28, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-318748142
https://github.com/masaeedu
Asad Saeeduddin (masaeedu)https://github.com/masaeedu
on Aug 10, 2017https://github.com/microsoft/TypeScript/issues/15114#issuecomment-321455766
master...masaeedu:masterhttps://github.com/microsoft/TypeScript/compare/master...masaeedu:master
microsofthttps://github.com/microsoft
on Jun 21, 2018https://github.com/microsoft/TypeScript/issues/15114#event-1694513271
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/15114
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/15114
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.