René's URL Explorer Experiment


Title: Callback argument type not inferred for union of interfaces · Issue #59309 · microsoft/TypeScript · GitHub

Open Graph Title: Callback argument type not inferred for union of interfaces · Issue #59309 · microsoft/TypeScript

X Title: Callback argument type not inferred for union of interfaces · Issue #59309 · microsoft/TypeScript

Description: 🔎 Search Terms "implicitly has an" inference 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about "inference" ⏯ Playground Link https://www.typescriptlang.org/play/?ta...

Open Graph Description: 🔎 Search Terms "implicitly has an" inference 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about "inference" ⏯ Playground Link...

X Description: 🔎 Search Terms "implicitly has an" inference 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about "inference...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Callback argument type not inferred for union of interfaces","articleBody":"### 🔎 Search Terms\r\n\r\n`\"implicitly has an\" inference`\r\n\r\n### 🕗 Version \u0026 Regression Information\r\n\r\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about \"inference\"\r\n\r\n\r\n### ⏯ Playground Link\r\n\r\nhttps://www.typescriptlang.org/play/?target=5\u0026ts=5.5.3#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgQQGcBPJbAJWEIFcAbGAYU1toCMcBrAHgBUAaOAFE4AXiFQo0AHxwA3gFgAUHBVwAFGigB+AFxC4AHzhI6tAVCp0YuuDwCUegG4QEAEwDcSgL5KloSLCIKGhYuAQkZJQ09ACSqFCYMNC8AuQCwmKCEtJySqrqCKgAtnr8cNjMbJx6RKQUlvRMLOzY3GlCUg5wzm6eij6K-tDwyPGheLWRDTBxaInQAAqSRQiEwClw5DIKyqpqhcAltl1LECtrXFt9A0quwNi0mBZw6NRkMAgQSHBFmGAAMggVjANu0MuJJFApGo8qonlBSgBtAC6fFhKloQMKehMRVYaDRuxUBwSSQRKkm9WiM3i8ygp3O6zKW0M4TqUSss1JyWZ6SkhJOy1W63IKKkfSUvwBWJgakRAEY+AAmPgAZlRcFVAkwEWw6iQdlE23RcAsMGoUG+3wAVNa4ErrnZ3EA\r\n\r\n### 💻 Code\r\n\r\n```ts\r\nexport interface AsyncResultCallback\u003cT, E = Error\u003e {\r\n    (err?: E | null, result?: T): void;\r\n}\r\n\r\nexport interface AsyncResultIterator\u003cT, R, E = Error\u003e {\r\n    (item: T, callback: AsyncResultCallback\u003cR, E\u003e): void;\r\n}\r\nexport interface AsyncResultIteratorPromise\u003cT, R\u003e {\r\n    (item: T): Promise\u003cR\u003e;\r\n}\r\n\r\ndeclare function mapLimit\u003cT, R, E = Error\u003e(\r\n    arr: T[],\r\n    limit: number,\r\n    iterator:  AsyncResultIteratorPromise\u003cT, R\u003e | AsyncResultIterator\u003cT, R, E\u003e,\r\n): Promise\u003cR[]\u003e;\r\n\r\nmapLimit([1,2,3], 3, async (n) =\u003e {\r\n    return n ** 2;\r\n});\r\n```\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\nThe type of `n` in the `mapLimit` callback is inferred as `any`:\r\n\r\n```\r\nParameter 'n' implicitly has an 'any' type. (7006)\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nI would expect the type of `n` to be inferred as `number`.\r\n\r\n### Additional information about the issue\r\n\r\nThis example is based on the types for the `async` package:\r\n\r\nhttps://github.com/DefinitelyTyped/DefinitelyTyped/blob/b9820410f85f259cbad6065d8cb6f23f403109ac/types/async/index.d.ts#L321-L325\r\n\r\nNote that if the type for `iterator` in `mapLimit` is changed to either just `AsyncResultIteratorPromise\u003cT, R\u003e` or just `AsyncResultIterator\u003cT, R, E\u003e` (that is, no longer a union type), things work as expected and `n` has type `number`.\r\n\r\nI found a very old discussion of what looks to be the same issue in the `DefinitelyTyped` repo: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/24297. The issue described there is exactly the one I'm facing. One commenter claimed that things worked correctly, and another commenter claimed that changing the way that `async` was imported had some effect? Neither of those sounds plausible to me.\r\n\r\nI found some issues that may describe the same or a similar problem:\r\n\r\n- https://github.com/microsoft/TypeScript/issues/56881\r\n- https://github.com/microsoft/TypeScript/issues/55632\r\n- https://github.com/microsoft/TypeScript/issues/52047\r\n- https://github.com/microsoft/TypeScript/issues/47599\r\n\r\nHowever, my knowledge of TypeScript internals/terminology isn't strong enough to say for sure that this isn't a novel issue I'm facing. If this is in fact a duplicate, please close it as such and I'll add this example to the relevant issue. Thank you!","author":{"url":"https://github.com/nwalters512","@type":"Person","name":"nwalters512"},"datePublished":"2024-07-16T21:16:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/59309/TypeScript/issues/59309"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a7b386a6-c945-29f8-5a1c-0cb7776d9ebf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBA74:FD1F4:4DB0BD:701333:6A61CE5F
html-safe-noncea2ea767ff7340ef974950bd049bd0420e3085020b6848814018670c208d8dc2f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTc0OkZEMUY0OjREQjBCRDo3MDEzMzM6NkE2MUNFNUYiLCJ2aXNpdG9yX2lkIjoiODI5ODU4NDkwMjAyODM2NTc1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac20451e3601c552afa9bf114359128e0fba3b6faa573f6737a7fa9980cc493f4e
hovercard-subject-tagissue:2412058822
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/59309/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e69a3ca71a5299965513542c7938c0ec4736debddf3e413925890412359d1e53/microsoft/TypeScript/issues/59309
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e69a3ca71a5299965513542c7938c0ec4736debddf3e413925890412359d1e53/microsoft/TypeScript/issues/59309
og:image:alt🔎 Search Terms "implicitly has an" inference 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about "inference" ⏯ Playground Link...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenwalters512
hostnamegithub.com
expected-hostnamegithub.com
Noneb2de8c74e5e61e893155ba46ee41bc66170c1644cb795adefa8386d490f7781c
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
released1866027ded575df8a15c731dd8b9986c9483ceb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/59309#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F59309
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%2F59309
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/59309
Reloadhttps://github.com/microsoft/TypeScript/issues/59309
Reloadhttps://github.com/microsoft/TypeScript/issues/59309
Please reload this pagehttps://github.com/microsoft/TypeScript/issues/59309
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
Callback argument type not inferred for union of interfaceshttps://github.com/microsoft/TypeScript/issues/59309#top
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20check%3A%20Type%20Inference%22
Help WantedYou can do thishttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Help%20Wanted%22
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some caseshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Possible%20Improvement%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/nwalters512
nwalters512https://github.com/nwalters512
on Jul 16, 2024https://github.com/microsoft/TypeScript/issues/59309#issue-2412058822
https://www.typescriptlang.org/play/?target=5&ts=5.5.3#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgQQGcBPJbAJWEIFcAbGAYU1toCMcBrAHgBUAaOAFE4AXiFQo0AHxwA3gFgAUHBVwAFGigB+AFxC4AHzhI6tAVCp0YuuDwCUegG4QEAEwDcSgL5KloSLCIKGhYuAQkZJQ09ACSqFCYMNC8AuQCwmKCEtJySqrqCKgAtnr8cNjMbJx6RKQUlvRMLOzY3GlCUg5wzm6eij6K-tDwyPGheLWRDTBxaInQAAqSRQiEwClw5DIKyqpqhcAltl1LECtrXFt9A0quwNi0mBZw6NRkMAgQSHBFmGAAMggVjANu0MuJJFApGo8qonlBSgBtAC6fFhKloQMKehMRVYaDRuxUBwSSQRKkm9WiM3i8ygp3O6zKW0M4TqUSss1JyWZ6SkhJOy1W63IKKkfSUvwBWJgakRAEY+AAmPgAZlRcFVAkwEWw6iQdlE23RcAsMGoUG+3wAVNa4ErrnZ3EAhttps://www.typescriptlang.org/play/?target=5&ts=5.5.3#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgQQGcBPJbAJWEIFcAbGAYU1toCMcBrAHgBUAaOAFE4AXiFQo0AHxwA3gFgAUHBVwAFGigB+AFxC4AHzhI6tAVCp0YuuDwCUegG4QEAEwDcSgL5KloSLCIKGhYuAQkZJQ09ACSqFCYMNC8AuQCwmKCEtJySqrqCKgAtnr8cNjMbJx6RKQUlvRMLOzY3GlCUg5wzm6eij6K-tDwyPGheLWRDTBxaInQAAqSRQiEwClw5DIKyqpqhcAltl1LECtrXFt9A0quwNi0mBZw6NRkMAgQSHBFmGAAMggVjANu0MuJJFApGo8qonlBSgBtAC6fFhKloQMKehMRVYaDRuxUBwSSQRKkm9WiM3i8ygp3O6zKW0M4TqUSss1JyWZ6SkhJOy1W63IKKkfSUvwBWJgakRAEY+AAmPgAZlRcFVAkwEWw6iQdlE23RcAsMGoUG+3wAVNa4ErrnZ3EA
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b9820410f85f259cbad6065d8cb6f23f403109ac/types/async/index.d.ts#L321-L325https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b9820410f85f259cbad6065d8cb6f23f403109ac/types/async/index.d.ts#L321-L325
DefinitelyTyped/DefinitelyTyped#24297https://github.com/DefinitelyTyped/DefinitelyTyped/issues/24297
Contextual parameter types failed to be provided based on filtering mapped types #56881https://github.com/microsoft/TypeScript/issues/56881
No type inferrence of callback arguments inside a tuple union type #55632https://github.com/microsoft/TypeScript/issues/55632
Callback parameter inference not working when part of an inferred tuple type #52047https://github.com/microsoft/TypeScript/issues/52047
Improve inference in the presence of context-sensitive expressions #47599https://github.com/microsoft/TypeScript/issues/47599
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20check%3A%20Type%20Inference%22
Help WantedYou can do thishttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Help%20Wanted%22
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some caseshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Possible%20Improvement%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.