René's URL Explorer Experiment


Title: Conditional type does not narrow union type · Issue #29188 · microsoft/TypeScript · GitHub

Open Graph Title: Conditional type does not narrow union type · Issue #29188 · microsoft/TypeScript

X Title: Conditional type does not narrow union type · Issue #29188 · microsoft/TypeScript

Description: TypeScript Version: 3.2.2 Search Terms: conditional types, unions, narrowing Code interface A { value: T; } interface Specification { [key: string]: Array | Specification; } type Mapping = { [key in keyof...

Open Graph Description: TypeScript Version: 3.2.2 Search Terms: conditional types, unions, narrowing Code interface A { value: T; } interface Specification { [key: string]: Array | Specification; } type Mapping

X Description: TypeScript Version: 3.2.2 Search Terms: conditional types, unions, narrowing Code interface A<T> { value: T; } interface Specification { [key: string]: Array<any> | Specification; } typ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Conditional type does not narrow union type","articleBody":"**TypeScript Version:**  3.2.2\r\n\r\n**Search Terms:** conditional types, unions, narrowing\r\n\r\n**Code**\r\n\r\n```ts\r\n    interface A\u003cT> {\r\n        value: T;\r\n    }\r\n\r\n    interface Specification {\r\n        [key: string]: Array\u003cany> | Specification;\r\n    }\r\n\r\n    type Mapping\u003cS extends Specification> = {\r\n        [key in keyof S]: S[key] extends Array\u003cinfer T> ? A\u003cT> : Mapping\u003cS[key]>\r\n        // Error                                                         ^^^^^^\r\n        // Type 'S[key]' does not satisfy the constraint 'Specification'.\r\n        //   Type 'Specification[key]' is not assignable to type 'Specification'.\r\n        //     Type 'any[] | Specification' is not assignable to type 'Specification'.\r\n        //       Type 'any[]' is not assignable to type 'Specification'.\r\n        //         Index signature is missing in type 'any[]'.\r\n    };\r\n```\r\n\r\n**Expected behavior:**\r\nNo error. \"Leafs\" of the `Specification` tree, which have type `Array\u003cT>` (for some `T`) should be mapped to `A\u003cT>`, while non-leaf properties should be recursively mapped.\r\n\r\n**Actual behavior:**\r\nIn the right-hand side of the conditional type, `S[key]` is not narrowed to `Specification`, even if the complete type of `S[key]` is `Array\u003cany> | Specification` and the `Array\u003cany>` case is catched in the left-hand side.\r\n\r\n**Playground Link:** [link](http://www.typescriptlang.org/play/#src=%0D%0Ainterface%20A%3CT%3E%20%7B%0D%0A%20%20%20%20value%3A%20T%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20Specification%20%7B%0D%0A%20%20%20%20%5Bkey%3A%20string%5D%3A%20Array%3Cany%3E%20%7C%20Specification%3B%0D%0A%7D%0D%0A%0D%0Atype%20Mapping%3CS%20extends%20Specification%3E%20%3D%20%7B%0D%0A%20%20%20%20%5Bkey%20in%20keyof%20S%5D%3A%20S%5Bkey%5D%20extends%20Array%3Cinfer%20T%3E%20%3F%20A%3CT%3E%20%3A%20Mapping%3CS%5Bkey%5D%3E%0D%0A%7D%3B%0D%0A)\r\n\r\n**Related Issues**: some similar issues related to conditional types, but I'm not sure whether this is a duplicate of any of them.\r\n","author":{"url":"https://github.com/lodo1995","@type":"Person","name":"lodo1995"},"datePublished":"2018-12-28T15:39:59Z","url":"https://github.com/microsoft/TypeScript/issues/29188"}

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:7961dc68-0fb8-ca2c-ff4f-9e318285ceba
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEA48:3DF0BE:91818F:BE31CE:6B00E1B5
html-safe-noncecd7e6fff1d6dd29db4a6934a9fea73fe7d8cf2e6059600edd8056b8d91941b50
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTQ4OjNERjBCRTo5MTgxOEY6QkUzMUNFOjZCMDBFMUI1IiwidmlzaXRvcl9pZCI6IjYwNjQyODUwODgzMzY2MzQyOTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf3691e9d1a5b55bca9a073a7e99605849b55c70ef8910e8fb3abbac5e0b67c27
hovercard-subject-tagissue:394662927
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/29188/issue_layout
twitter:imagehttps://opengraph.githubassets.com/60a56d9ac945e5eaa0adc4f24e512aa52fa6fbcdb4438bc911a5be09bb54efc0/microsoft/TypeScript/issues/29188
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/60a56d9ac945e5eaa0adc4f24e512aa52fa6fbcdb4438bc911a5be09bb54efc0/microsoft/TypeScript/issues/29188
og:image:altTypeScript Version: 3.2.2 Search Terms: conditional types, unions, narrowing Code interface A { value: T; } interface Specification { [key: string]: Array | Specification; } type Mapping
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelodo1995
hostnamegithub.com
expected-hostnamegithub.com
None043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf
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
release5425dc24e8bd8d6fca9641a12afc984825a43875
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/29188#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F29188
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%2F29188
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/29188
Reloadhttps://github.com/microsoft/TypeScript/issues/29188
Reloadhttps://github.com/microsoft/TypeScript/issues/29188
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests309 (309)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/29188
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/29188
Conditional type does not narrow union typehttps://github.com/microsoft/TypeScript/issues/29188#top
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/lodo1995
Lodovico Giaretta (lodo1995)https://github.com/lodo1995
on Dec 28, 2018https://github.com/microsoft/TypeScript/issues/29188#issue-394662927
linkhttp://www.typescriptlang.org/play/#src=%0D%0Ainterface%20A%3CT%3E%20%7B%0D%0A%20%20%20%20value%3A%20T%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20Specification%20%7B%0D%0A%20%20%20%20%5Bkey%3A%20string%5D%3A%20Array%3Cany%3E%20%7C%20Specification%3B%0D%0A%7D%0D%0A%0D%0Atype%20Mapping%3CS%20extends%20Specification%3E%20%3D%20%7B%0D%0A%20%20%20%20%5Bkey%20in%20keyof%20S%5D%3A%20S%5Bkey%5D%20extends%20Array%3Cinfer%20T%3E%20%3F%20A%3CT%3E%20%3A%20Mapping%3CS%5Bkey%5D%3E%0D%0A%7D%3B%0D%0A
https://github.com/fatcerberus
Bruce Pascoe (fatcerberus)https://github.com/fatcerberus
on Dec 28, 2018https://github.com/microsoft/TypeScript/issues/29188#issuecomment-450379612
https://github.com/lodo1995
Lodovico Giaretta (lodo1995)https://github.com/lodo1995
on Dec 28, 2018https://github.com/microsoft/TypeScript/issues/29188#issuecomment-450382167
https://github.com/jack-williams
Jack Williams (jack-williams)https://github.com/jack-williams
on Jan 3, 2019https://github.com/microsoft/TypeScript/issues/29188#issuecomment-451104440
#24821https://github.com/microsoft/TypeScript/pull/24821
https://github.com/lmcarreiro
Leonardo Carreiro (lmcarreiro)https://github.com/lmcarreiro
on Jan 3, 2019https://github.com/microsoft/TypeScript/issues/29188#issuecomment-451132308
https://github.com/jack-williams
Jack Williams (jack-williams)https://github.com/jack-williams
on Jan 3, 2019https://github.com/microsoft/TypeScript/issues/29188#issuecomment-451152861
Leonardo Carreiro (@lmcarreiro)https://github.com/lmcarreiro
Wesley Wigham (@weswigham)https://github.com/weswigham
#29011https://github.com/microsoft/TypeScript/pull/29011
https://github.com/weswigham
Wesley Wigham (weswigham)https://github.com/weswigham
on Jan 3, 2019https://github.com/microsoft/TypeScript/issues/29188#issuecomment-451238804
Jack Williams (@jack-williams)https://github.com/jack-williams
Lodovico Giaretta (@lodo1995)https://github.com/lodo1995
#29011https://github.com/microsoft/TypeScript/pull/29011
Wesley Wigham (weswigham)https://github.com/weswigham
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Domain: Conditional TypesThe issue relates to conditional typeshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20Conditional%20Types%22
on Jan 3, 2019https://github.com/microsoft/TypeScript/issues/29188#event-2053058514
https://github.com/fatcerberus
Bruce Pascoe (fatcerberus)https://github.com/fatcerberus
on Jan 3, 2019https://github.com/microsoft/TypeScript/issues/29188#issuecomment-451241873
https://github.com/falsandtru
falsandtru (falsandtru)https://github.com/falsandtru
on Feb 2, 2019https://github.com/microsoft/TypeScript/issues/29188#issuecomment-459936687
#21937https://github.com/microsoft/TypeScript/issues/21937
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Backloghttps://github.com/microsoft/TypeScript/milestone/29
on Mar 14, 2019https://github.com/microsoft/TypeScript/issues/29188#event-2204259519
https://github.com/TotallyNotChase
Chase (TotallyNotChase)https://github.com/TotallyNotChase
on Jan 7, 2021https://github.com/microsoft/TypeScript/issues/29188#issuecomment-756301061
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 27, 2026https://github.com/microsoft/TypeScript/issues/29188#issuecomment-5445540101
Why can't I narrow or assign to a generic type parameter the way I can with its constraint?https://github.com/microsoft/TypeScript/wiki/FAQ#why-cant-i-narrow-or-assign-to-a-generic-type-parameter-the-way-i-can-with-its-constraint
Exclude Isn't Type Negationhttps://github.com/microsoft/TypeScript/wiki/FAQ#exclude-isnt-type-negation
#4196https://github.com/microsoft/TypeScript/issues/4196
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs Human ReviewThis issue has a backlog check awaiting maintainer review.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Human%20Review%22
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%22
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Domain: Conditional TypesThe issue relates to conditional typeshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20Conditional%20Types%22
Needs Human ReviewThis issue has a backlog check awaiting maintainer review.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Human%20Review%22
on Aug 27, 2026https://github.com/microsoft/TypeScript/issues/29188#event-30131992765
https://github.com/weswigham
Wesley Wigham (weswigham)https://github.com/weswigham
on Aug 27, 2026https://github.com/microsoft/TypeScript/issues/29188#issuecomment-5445952540
#63926https://github.com/microsoft/TypeScript/pull/63926
https://github.com/apps/typescript-automation
typescript-automationhttps://github.com/apps/typescript-automation
on Aug 30, 2026https://github.com/microsoft/TypeScript/issues/29188#issuecomment-5465984036
TypeScript Automationhttps://github.com/microsoft/TypeScript
typescript-automationhttps://github.com/apps/typescript-automation
not plannedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Aug 30, 2026https://github.com/microsoft/TypeScript/issues/29188#event-30224894622
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/29188
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/29188
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%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.