René's URL Explorer Experiment


Title: Conditional types incorrect for complex types · Issue #35533 · microsoft/TypeScript · GitHub

Open Graph Title: Conditional types incorrect for complex types · Issue #35533 · microsoft/TypeScript

X Title: Conditional types incorrect for complex types · Issue #35533 · microsoft/TypeScript

Description: TypeScript Version: 3.7.2 I'm seeing incorrect behavior when I extend a computed type that's more than a few levels deep. When I explicitly define the type, I don't see the same behavior. I'm guessing that complex types are getting impli...

Open Graph Description: TypeScript Version: 3.7.2 I'm seeing incorrect behavior when I extend a computed type that's more than a few levels deep. When I explicitly define the type, I don't see the same behavior. I'm guess...

X Description: TypeScript Version: 3.7.2 I'm seeing incorrect behavior when I extend a computed type that's more than a few levels deep. When I explicitly define the type, I don't see the same behavio...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Conditional types incorrect for complex types","articleBody":"**TypeScript Version:**  3.7.2\r\n\r\nI'm seeing incorrect behavior when I `extend` a computed type that's more than a few levels deep. When I explicitly define the type, I don't see the same behavior. I'm guessing that complex types are getting implicitly cast to `any` in this circumstance – tsc should probably either instantiate the correct type or cast them to `unknown` with a warning when they're too big.\r\n\r\nThis is admittedly a contrived example but I've run into similar issues when, for example, developing https://github.com/ostrowr/ts-json-validator\r\n\r\n**Search Terms:**\r\ndepth, conditional types, extends, implicit any\r\n\r\n**Expected behavior:**\r\n`shouldBeFalse` and `correctlyFalseWhenExpanded` are both `false` (see code snippet below)\r\n\r\n**Actual behavior:**\r\n`shouldBeFalse` is True (i.e. 6 == 5 in my contrived version of Peano arithmetic) \r\n\r\n**Related Issues:**\r\n- https://github.com/microsoft/TypeScript/issues/30152 (maybe related)\r\n- https://github.com/microsoft/TypeScript/issues/29511 (discussion around implicit casts to any)\r\n\r\n**Code**\r\n```ts\r\ntype Natural = { prev: Natural }\r\ntype Zero = { prev: never }\r\n\r\ntype Equals\u003cA extends Natural, B extends Natural> =\r\n    A extends B ?\r\n        B extends A ?\r\n        true :\r\n        false : \r\n    false\r\n\r\ntype S\u003cT extends Natural> = { prev: T }\r\n\r\ntype One = S\u003cZero>\r\ntype Two = S\u003cOne>\r\ntype Three = S\u003cTwo>\r\ntype Four = S\u003cThree>\r\ntype Five = S\u003cFour>\r\ntype FiveByHand = { // this is the exact same type as Five, just manually expanded\r\n    prev: {\r\n        prev: {\r\n            prev: {\r\n                prev: {\r\n                    prev: {\r\n                        prev: never;\r\n                    };\r\n                };\r\n            };\r\n        };\r\n    };\r\n}\r\ntype Six = S\u003cFive>\r\ntype SixByHand = { // this is the exact same type as Six, just manually expanded\r\n    prev: {\r\n        prev: {\r\n            prev: {\r\n                prev: {\r\n                    prev: {\r\n                        prev: {\r\n                            prev: never;\r\n                        };\r\n                    };\r\n                };\r\n            };\r\n        };\r\n    };\r\n}\r\ntype correctlyFalseForShallowTypes = Equals\u003cFour, Five> // type: false\r\ntype correctlyTrue = Equals\u003cFour, Four> // type: true\r\ntype shouldBeFalse = Equals\u003cFive, Six> // type: true (should be false!)\r\ntype correctlyFalseWhenExpanded = Equals\u003cFiveByHand, SixByHand> // type: false (as expected)\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\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](http://www.typescriptlang.org/play/#code/C4TwDgpgBAcghsArgJzgGygXigbymZCANwC5YEV0oBfAKFEigC0JkB7LXfQ0qAO2KsateuGgBRAI6J0AZwA8AQSgQAHsAh8AJrPJJUaADRQAQivWadeymgB8WWlCdRlajdt1mA-I+d+zbpa6yj5+fsDIiNAkvmFQAGZy0VCxCUkiDNAAyvIAKubuVvD66PbYeATEZPl0oowA8gKcOSzstnXQuQDuHNg5jRDtmVC5ABaE0H15PUNiUABibCjNeeMQgx0LAJZEk1A5iyizjPM7ECYgABJw2px4APT3UMCjW7pvz6PQanAAxsBQWRwAC20GGcF0p12xgAVohZADgTcZGg0CBzGAbloIFpUpVeDhUn58WRCXE4iTcETycSeKTqTSKXSqYzWWFKQJdsgANwMtlOai8-l+QV8kVC8mi8W0OjDLJbVQrKEbOUKi7XW7lKCPT4fD4vb6qP4AoGg55zCH7BWw+GI5HoNEYrE4vHMsnkynu1mesUet2+73+4Vsn3B4McwQ8gPCqVh6Vx2OsxNhZOi2VzX5sZCEf5o+ZJRbILKjB1sLq5MS6bBSFEKQ7IYzK+w6zJkRJoWQQTaZ7MQXMgXKRPY1uTyeuNpbIZtPVvPIebWSjJZoLQmCD5jvD6Sj5XGeWqafmyBkCJRKAACkXy60UAARtB252AIQASm7WZzwDzSQA6l8+OIqiYtoOKcCOHZjmc6pYnuapXFih6zo+0DnpaaiQP8OJviIC5wRqN7lK6VQsn6xFeoyoZhpRcZONRNG0mR0ZxhGXISvR8bscm-JcZKbEpnxaZAA)","author":{"url":"https://github.com/ostrowr","@type":"Person","name":"ostrowr"},"datePublished":"2019-12-06T00:44:17Z","url":"https://github.com/microsoft/TypeScript/issues/35533"}

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:f7609682-2042-42dc-4660-21304a4cf355
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA3DE:EDA7A:2A975B4:361E1C6:6B01AA6B
html-safe-nonce8499a245e6e9cd539e48f1c2a447a9898fec25567021d117e8d163dad7595a13
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0RFOkVEQTdBOjJBOTc1QjQ6MzYxRTFDNjo2QjAxQUE2QiIsInZpc2l0b3JfaWQiOiI2OTg4NDgwNDkzMzAxOTAxOTMyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac68ba7467341d256a414bcc7f9bd99690e6d71cd936b4d2b56b1aed7cc2e10644
hovercard-subject-tagissue:533680031
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/35533/issue_layout
twitter:imagehttps://opengraph.githubassets.com/99c89e54c4e920992fe75febf701f4e5fb0f873ecb6258d666e39361ae4e00fd/microsoft/TypeScript/issues/35533
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/99c89e54c4e920992fe75febf701f4e5fb0f873ecb6258d666e39361ae4e00fd/microsoft/TypeScript/issues/35533
og:image:altTypeScript Version: 3.7.2 I'm seeing incorrect behavior when I extend a computed type that's more than a few levels deep. When I explicitly define the type, I don't see the same behavior. I'm guess...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameostrowr
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/35533#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F35533
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%2F35533
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/35533
Reloadhttps://github.com/microsoft/TypeScript/issues/35533
Reloadhttps://github.com/microsoft/TypeScript/issues/35533
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/35533
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/35533
Conditional types incorrect for complex typeshttps://github.com/microsoft/TypeScript/issues/35533#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
https://github.com/ostrowr
Robbie Ostrow (ostrowr)https://github.com/ostrowr
on Dec 6, 2019https://github.com/microsoft/TypeScript/issues/35533#issue-533680031
https://github.com/ostrowr/ts-json-validatorhttps://github.com/ostrowr/ts-json-validator
Conditional types are incorrectly narrowed  #30152https://github.com/microsoft/TypeScript/issues/30152
[API Question] Is there a type resolution depth limit difference between compiling and running the language service? #29511https://github.com/microsoft/TypeScript/issues/29511
Providedhttp://www.typescriptlang.org/play/#code/C4TwDgpgBAcghsArgJzgGygXigbymZCANwC5YEV0oBfAKFEigC0JkB7LXfQ0qAO2KsateuGgBRAI6J0AZwA8AQSgQAHsAh8AJrPJJUaADRQAQivWadeymgB8WWlCdRlajdt1mA-I+d+zbpa6yj5+fsDIiNAkvmFQAGZy0VCxCUkiDNAAyvIAKubuVvD66PbYeATEZPl0oowA8gKcOSzstnXQuQDuHNg5jRDtmVC5ABaE0H15PUNiUABibCjNeeMQgx0LAJZEk1A5iyizjPM7ECYgABJw2px4APT3UMCjW7pvz6PQanAAxsBQWRwAC20GGcF0p12xgAVohZADgTcZGg0CBzGAbloIFpUpVeDhUn58WRCXE4iTcETycSeKTqTSKXSqYzWWFKQJdsgANwMtlOai8-l+QV8kVC8mi8W0OjDLJbVQrKEbOUKi7XW7lKCPT4fD4vb6qP4AoGg55zCH7BWw+GI5HoNEYrE4vHMsnkynu1mesUet2+73+4Vsn3B4McwQ8gPCqVh6Vx2OsxNhZOi2VzX5sZCEf5o+ZJRbILKjB1sLq5MS6bBSFEKQ7IYzK+w6zJkRJoWQQTaZ7MQXMgXKRPY1uTyeuNpbIZtPVvPIebWSjJZoLQmCD5jvD6Sj5XGeWqafmyBkCJRKAACkXy60UAARtB252AIQASm7WZzwDzSQA6l8+OIqiYtoOKcCOHZjmc6pYnuapXFih6zo+0DnpaaiQP8OJviIC5wRqN7lK6VQsn6xFeoyoZhpRcZONRNG0mR0ZxhGXISvR8bscm-JcZKbEpnxaZAA
https://github.com/rusev
Nikolay Rusev (rusev)https://github.com/rusev
on Dec 10, 2019https://github.com/microsoft/TypeScript/issues/35533#issuecomment-563909025
This Build 2018 presentationhttps://www.youtube.com/watch?v=hDACN-BGvI8&feature=youtu.be&t=22m59s
https://github.com/ostrowr
Robbie Ostrow (ostrowr)https://github.com/ostrowr
on Dec 13, 2019https://github.com/microsoft/TypeScript/issues/35533#issuecomment-565545656
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%22
on Jan 15, 2020https://github.com/microsoft/TypeScript/issues/35533#event-2951283378
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jan 15, 2020https://github.com/microsoft/TypeScript/issues/35533#issuecomment-574719956
https://github.com/ostrowr
Robbie Ostrow (ostrowr)https://github.com/ostrowr
on Jan 15, 2020https://github.com/microsoft/TypeScript/issues/35533#issuecomment-574760320
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 1, 2021https://github.com/microsoft/TypeScript/issues/35533#event-4828178153
https://github.com/ostrowr
Robbie Ostrow (ostrowr)https://github.com/ostrowr
on Dec 14, 2021https://github.com/microsoft/TypeScript/issues/35533#issuecomment-993064067
#46599https://github.com/microsoft/TypeScript/pull/46599
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/35533
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/35533
Design LimitationConstraints of the existing architecture prevent this from being fixedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Design%20Limitation%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.