René's URL Explorer Experiment


Title: Inference doesn't find common base type for union with null or undefined - TypeScript 4.8 regression · Issue #49938 · microsoft/TypeScript · GitHub

Open Graph Title: Inference doesn't find common base type for union with null or undefined - TypeScript 4.8 regression · Issue #49938 · microsoft/TypeScript

X Title: Inference doesn't find common base type for union with null or undefined - TypeScript 4.8 regression · Issue #49938 · microsoft/TypeScript

Description: Bug Report 🔎 Search Terms inference common base type null undefined 🕗 Version & Regression Information This changed between versions 4.7.3 and 4.8-beta ⏯ Playground Link Playground link with relevant code 💻 Code function equal(a: T, b...

Open Graph Description: Bug Report 🔎 Search Terms inference common base type null undefined 🕗 Version & Regression Information This changed between versions 4.7.3 and 4.8-beta ⏯ Playground Link Playground link with releva...

X Description: Bug Report 🔎 Search Terms inference common base type null undefined 🕗 Version & Regression Information This changed between versions 4.7.3 and 4.8-beta ⏯ Playground Link Playground link with re...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inference doesn't find common base type for union with null or undefined - TypeScript 4.8 regression","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\ninference common base type null undefined \r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This changed between versions 4.7.3 and 4.8-beta\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?ts=4.8.0-beta#code/GYVwdgxgLglg9mABAUwI4gIYBsA8AVAPgAoMAuRPAGkQCNy8BKRAb0QF8AoDrZKRAN0QBeRGBBYsAQgDcXDgHp5iAPI0AVsmiIoATwAOyAM6IA7jCgALRBDgBbWwloZDybfqNddBxACFhLRGA4OHJDKAAnGDAAc3YOL1cAEX9WIJDEMMiY6Sdw8jFbGmRwuIUlAFFw8LgSqMQAFgA6AA4KAGVrDDAAcj5gKIATazsHJATEQBlyMobGgHYKU2dEcAHkfrBkIYAfXw40TCwiQSWfamPjFbWozcQdxIYuRUQ4AGsFmGM-QFByPfRsI8QJzOgOM92mr3en1uyzAq3WNx++3+518wJO0Mu8IGDwUACpcRxELiVJZiigAB4YWx6HiGQm4+SPJQABUitnMMH4RkBsMQWHMxWwdOmlWqtSQTVaeA6EC6vUCg2G9kc4ymTya8zwiwusKuG22ohAhWKvwOAKWBSK4TROrh1wNAAZoQBGaEAJhxTwhWo+huNJURf0OKMtxRtiEQTp2rp2HtkXrePuMoZKO0x9sQgbNIaNVvDfqtGN1WIYsiZiAAglUMDpjGZLErRk4XG4DMKnqKaog6pL2p0en1FTZlWN3JNphqFiYlun9dCiCnoZkotEGABtAC6puRIMQC9zZJ2y5i6434dnNx2Kc3nqU3u7xn3-qXERXp8z2+Du6fhaPr5Pm7hteG4PAmkJ7ouf5ZKum5Fnac5ZjuSw-oeGT-jBZ4CN+kFodB75psW9oPEAA)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\nfunction equal\u003cT>(a: T, b: T) { }\r\n\r\nlet v = null!;\r\n\r\n// Object types with common base types\r\n\r\ntype B = { foo: string }\r\ntype D = { foo: string; bar: number }\r\n\r\n// Error in 4.8 TS can't find common type ❌\r\n// 4.7 T was undefined | B\r\nequal(v as B, v as undefined | D)\r\n\r\n// ok T is B ✅\r\nequal(v as B, v as D)\r\n// ok T is B | undefined ✅\r\nequal(v as B, v as B | undefined)\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nIn 4.8 TypeScript can't find common base type between `B` and `undefined | D`. In 4.7 this used to be `B | undefined`. \r\n\r\nThis also happens for literal types and their respective base types as well as for arrays as shown in the 'Other Examples' in the playground link. I didn't include the code as the bug is the same, it's just different instances we found in our code.\r\n\r\n### 🙂 Expected behavior\r\n\r\nTypescript finds the type `B | undefined` for `T` as it did in 4.7.\r\n","author":{"url":"https://github.com/dragomirtitian","@type":"Person","name":"dragomirtitian"},"datePublished":"2022-07-18T08:55:50Z","url":"https://github.com/microsoft/TypeScript/issues/49938"}

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:006fb211-e784-c7d7-c4e5-5398cfc9c7cf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9ECA:16AB79:C6ECD5:FDE6C1:6B00FF2A
html-safe-nonced4703a0ab86476cc4e8274a905fc8135097530ebda14b2e53bb8cd9f72d16ccf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUNBOjE2QUI3OTpDNkVDRDU6RkRFNkMxOjZCMDBGRjJBIiwidmlzaXRvcl9pZCI6Ijg1MTMxNDE0OTc2NjU3NDg3NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1280ec46565e24265c13e887456dfb61dbfe6bb13e0954127eaedad545e864d1
hovercard-subject-tagissue:1307614581
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/49938/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b3c3287c577e7416f7e6800ccd85ffd00ba95785ad9b8a2e3569da470e97b617/microsoft/TypeScript/issues/49938
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b3c3287c577e7416f7e6800ccd85ffd00ba95785ad9b8a2e3569da470e97b617/microsoft/TypeScript/issues/49938
og:image:altBug Report 🔎 Search Terms inference common base type null undefined 🕗 Version & Regression Information This changed between versions 4.7.3 and 4.8-beta ⏯ Playground Link Playground link with releva...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedragomirtitian
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
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
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/49938#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F49938
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%2F49938
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/49938
Reloadhttps://github.com/microsoft/TypeScript/issues/49938
Reloadhttps://github.com/microsoft/TypeScript/issues/49938
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/49938
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/49938
Inference doesn't find common base type for union with null or undefined - TypeScript 4.8 regressionhttps://github.com/microsoft/TypeScript/issues/49938#top
https://github.com/jakebailey
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
TypeScript 4.8.1https://github.com/microsoft/TypeScript/milestone/165
https://github.com/dragomirtitian
Titian Cernicova-Dragomir (dragomirtitian)https://github.com/dragomirtitian
on Jul 18, 2022https://github.com/microsoft/TypeScript/issues/49938#issue-1307614581
Playground link with relevant codehttps://www.typescriptlang.org/play?ts=4.8.0-beta#code/GYVwdgxgLglg9mABAUwI4gIYBsA8AVAPgAoMAuRPAGkQCNy8BKRAb0QF8AoDrZKRAN0QBeRGBBYsAQgDcXDgHp5iAPI0AVsmiIoATwAOyAM6IA7jCgALRBDgBbWwloZDybfqNddBxACFhLRGA4OHJDKAAnGDAAc3YOL1cAEX9WIJDEMMiY6Sdw8jFbGmRwuIUlAFFw8LgSqMQAFgA6AA4KAGVrDDAAcj5gKIATazsHJATEQBlyMobGgHYKU2dEcAHkfrBkIYAfXw40TCwiQSWfamPjFbWozcQdxIYuRUQ4AGsFmGM-QFByPfRsI8QJzOgOM92mr3en1uyzAq3WNx++3+518wJO0Mu8IGDwUACpcRxELiVJZiigAB4YWx6HiGQm4+SPJQABUitnMMH4RkBsMQWHMxWwdOmlWqtSQTVaeA6EC6vUCg2G9kc4ymTya8zwiwusKuG22ohAhWKvwOAKWBSK4TROrh1wNAAZoQBGaEAJhxTwhWo+huNJURf0OKMtxRtiEQTp2rp2HtkXrePuMoZKO0x9sQgbNIaNVvDfqtGN1WIYsiZiAAglUMDpjGZLErRk4XG4DMKnqKaog6pL2p0en1FTZlWN3JNphqFiYlun9dCiCnoZkotEGABtAC6puRIMQC9zZJ2y5i6434dnNx2Kc3nqU3u7xn3-qXERXp8z2+Du6fhaPr5Pm7hteG4PAmkJ7ouf5ZKum5Fnac5ZjuSw-oeGT-jBZ4CN+kFodB75psW9oPEAA
https://github.com/dragomirtitian
Titian Cernicova-Dragomir (dragomirtitian)https://github.com/dragomirtitian
on Jul 18, 2022https://github.com/microsoft/TypeScript/issues/49938#issuecomment-1186941651
#49835https://github.com/microsoft/TypeScript/issues/49835
https://github.com/jakebailey
Jake Bailey (jakebailey)https://github.com/jakebailey
on Jul 19, 2022https://github.com/microsoft/TypeScript/issues/49938#issuecomment-1189439871
#49119https://github.com/microsoft/TypeScript/pull/49119
https://github.com/jakebailey
Jake Bailey (jakebailey)https://github.com/jakebailey
on Jul 20, 2022https://github.com/microsoft/TypeScript/issues/49938#issuecomment-1190747884
Playground Linkhttps://www.typescriptlang.org/play?ts=4.8.0-beta#code/GYVwdgxgLglg9mABAUwI4gIYBsA8AVAPgAoMAuRPAGkQCNy8BKRAb0QF8AoDrZKRAN0QBeRGBBYsAQgDcXDgHp5iAPI0AVsmiIoATwAOyAM6IA7jCgALRBDgBbWwloZDybfqNddBxACFhLRGA4OHJDKAAnGDAAc3YOL1cAEX9WIJDEMMiY6Sdw8jFbGmRwuIUlABYAOgB2clBIWEc0TFw-AB9EcAATZGAo5C7iMl9EDu7e-q7qOhGxsB6+sAGGcn44GC6yxCqADjrwaHgkZuwcHyHyH2nLlYF1zZOsIkFnX2oX43HFgdHERIYtgA9AD8XEU2xq+waRxQ6FOyTmC0mFz+vy+k2uqMREyWXVuaw2W12UMOTThuARnXmOIGKMp6NxmPp1O+eNW9w4j2eiFeDJ+HUS7x5xh8TCBoKJkMCB0ax3JZxRV1oN3ZhPBxOl0LJLQVJEumNFqs2nPJ3NeSo+fwB4JBYIqUvqpLlOvaVKRuMVaJZGOVszdNLZdzV9r2mqdsJdXvdtL1fr5U19rvj+PuAB0TS0zSKheaowHrUoQUA
https://github.com/jakebailey
Jake Bailey (jakebailey)https://github.com/jakebailey
on Jul 20, 2022https://github.com/microsoft/TypeScript/issues/49938#issuecomment-1190873508
https://github.com/microsoft/TypeScript/pull/49119/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8R21147https://github.com/microsoft/TypeScript/pull/49119/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8R21147
Jake Bailey (jakebailey)https://github.com/jakebailey
on Jul 20, 2022https://github.com/microsoft/TypeScript/issues/49938#event-7033632347
https://github.com/jakebailey
Jake Bailey (jakebailey)https://github.com/jakebailey
on Jul 21, 2022https://github.com/microsoft/TypeScript/issues/49938#issuecomment-1191731754
Playground Linkhttps://www.staging-typescript.org/play?ts=4.8.0-pr-49981-17#code/GYVwdgxgLglg9mABAUwI4gIYBsA8AVAPgAoMAuRPAGkQCNy8BKRAb0QF8AoDrZKRAN0QBeRGBBYsAQgDcXAPRzEAeRoArZNERQAngAdkAZ0QB3GFAAWiCHAC2NhLQwHkWvYa479iAELCWiYDg4cgMoACcYMABzdg5PFwARP1ZA4MRQiOjpRzDyMRsaZDDYjjRMLCJBJx9qKqNwABNkYEjkBsQAH0QEhg4FRAA9AH5S9GxKxGrG5tb2roTayaNvXv7hrjLsHGmWsDbOn2I6moElxB3Zg56+xXXN3Au9ucOJqbAm3f35xeqVm8GRqNyq9lj96u8Zk9VrcRvcQecIZ8GmCfNCARsxhVjt4Udc1rDMfCFqdfmj1kDxtiUb4uo82mSCcDsQc6ciScsGRwgA
Jake Bailey (jakebailey)https://github.com/jakebailey
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
on Jul 22, 2022https://github.com/microsoft/TypeScript/issues/49938#event-7048454852
Jake Bailey (jakebailey)https://github.com/jakebailey
TypeScript 4.8.1https://github.com/microsoft/TypeScript/milestone/165
on Jul 22, 2022https://github.com/microsoft/TypeScript/issues/49938#event-7048455364
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Jul 24, 2022https://github.com/microsoft/TypeScript/issues/49938#issuecomment-1193336792
#50021https://github.com/microsoft/TypeScript/pull/50021
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 24, 2022https://github.com/microsoft/TypeScript/issues/49938#event-7051538125
microsofthttps://github.com/microsoft
on Oct 22, 2025https://github.com/microsoft/TypeScript/issues/49938#event-20417570103
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/49938
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/49938
Jake Bailey (jakebailey)https://github.com/jakebailey
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
TypeScript 4.8.1https://github.com/microsoft/TypeScript/milestone/165
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.