René's URL Explorer Experiment


Title: Allow to use null as discriminator for tagged union · Issue #24193 · microsoft/TypeScript · GitHub

Open Graph Title: Allow to use null as discriminator for tagged union · Issue #24193 · microsoft/TypeScript

X Title: Allow to use null as discriminator for tagged union · Issue #24193 · microsoft/TypeScript

Description: Search Terms Suggestion Right now, even with strictNullChecks is set to true, null cannot be used as a discriminator for tagged union. Use Cases Recently, I made a pull request for @types/node in which I let spawnSync returns a tagged un...

Open Graph Description: Search Terms Suggestion Right now, even with strictNullChecks is set to true, null cannot be used as a discriminator for tagged union. Use Cases Recently, I made a pull request for @types/node in w...

X Description: Search Terms Suggestion Right now, even with strictNullChecks is set to true, null cannot be used as a discriminator for tagged union. Use Cases Recently, I made a pull request for @types/node in w...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow to use null as discriminator for tagged union","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Please read the FAQ first, especially the \"Common Feature Requests\" section.\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\n\u003c!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->\r\n\r\n## Suggestion\r\n\r\n\u003c!-- A summary of what you'd like to see added or changed -->\r\n\r\nRight now, even with `strictNullChecks` is set to `true`, `null` cannot be used as a discriminator for tagged union.\r\n\r\n## Use Cases\r\n\r\n\u003c!--\r\nWhat do you want to use this for?\r\nWhat shortcomings exist with current approaches?\r\n-->\r\n\r\nRecently, I made a [pull request](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/25731) for `@types/node` in which I let `spawnSync` returns a tagged union with `error` property as discriminator. \r\n\r\n## Examples\r\n\r\n\u003c!-- Show how this would be used and what the behavior would be -->\r\n\r\n```typescript\r\ninterface WithError {\r\n    error: Error\r\n    data: null\r\n}\r\n\r\ninterface WithoutError\u003cData> {\r\n    error: null\r\n    data: Data\r\n}\r\n\r\ntype DataCarrier\u003cData> = WithError | WithoutError\u003cData>\r\n\r\n// MAIN FOCUS:\r\n//   TypeScript should be able to deduce error's and data's\r\n//   types in the following function \r\nfunction test\u003cData>(carrier: DataCarrier\u003cData>) {\r\n    if (carrier.error === null) { // `error` property as disciminator\r\n        const error: null = carrier.error // should work\r\n        const data: Data = carrier.data // should work\r\n    } else {\r\n        const error: Error = carrier.error // should work\r\n        const data: null = carrier.data // should work\r\n    }\r\n}\r\n```\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n* [x] This wouldn't be a breaking change in existing TypeScript / JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. new expression-level syntax)\r\n\r\n","author":{"url":"https://github.com/KSXGitHub","@type":"Person","name":"KSXGitHub"},"datePublished":"2018-05-17T08:50:50Z","url":"https://github.com/microsoft/TypeScript/issues/24193"}

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:beec265e-75b0-8e1c-31a3-16a6d9ec008b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD36A:C24D0:59CC2F:7D362F:6B0481E1
html-safe-nonce5f59f5de76a72514a38bd6b4faee9598d3ce2e509a041378b3ec2a93666ff7fc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzZBOkMyNEQwOjU5Q0MyRjo3RDM2MkY6NkIwNDgxRTEiLCJ2aXNpdG9yX2lkIjoiMjgwMDkwNzU1NzQ1ODQ0NDc2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacd51170f4d6dd2d80b967d2035a13adecee878a0cbda99c1b0f2c534fcdbec542
hovercard-subject-tagissue:323928442
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/24193/issue_layout
twitter:imagehttps://opengraph.githubassets.com/86b34dbe2a1b797638d1efbd0c08617cec40cf8796f88caa1cf892900d244e29/microsoft/TypeScript/issues/24193
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/86b34dbe2a1b797638d1efbd0c08617cec40cf8796f88caa1cf892900d244e29/microsoft/TypeScript/issues/24193
og:image:altSearch Terms Suggestion Right now, even with strictNullChecks is set to true, null cannot be used as a discriminator for tagged union. Use Cases Recently, I made a pull request for @types/node in w...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKSXGitHub
hostnamegithub.com
expected-hostnamegithub.com
None0366ddfb372682a32e92a5d86155cb08fa83e5bbe79953a968789f2f7e24c511
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
releaseed3f2e01f6b7672780c586c8af0e72726374d7b6
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/24193#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F24193
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%2F24193
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/24193
Reloadhttps://github.com/microsoft/TypeScript/issues/24193
Reloadhttps://github.com/microsoft/TypeScript/issues/24193
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests319 (319)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/24193
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/24193
#27695https://github.com/microsoft/TypeScript/pull/27695
Allow to use null as discriminator for tagged unionhttps://github.com/microsoft/TypeScript/issues/24193#top
#27695https://github.com/microsoft/TypeScript/pull/27695
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 3.2https://github.com/microsoft/TypeScript/milestone/77
https://github.com/KSXGitHub
Khải (KSXGitHub)https://github.com/KSXGitHub
on May 17, 2018https://github.com/microsoft/TypeScript/issues/24193#issue-323928442
pull requesthttps://github.com/DefinitelyTyped/DefinitelyTyped/pull/25731
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on May 17, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-389802901
https://github.com/KSXGitHub
Khải (KSXGitHub)https://github.com/KSXGitHub
on May 17, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-389804298
Martin Johns (@MartinJohns)https://github.com/MartinJohns
https://github.com/ajafff
Klaus Meinhardt (ajafff)https://github.com/ajafff
on May 17, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-389818136
Khải (@KSXGitHub)https://github.com/KSXGitHub
https://github.com/KSXGitHub
Khải (KSXGitHub)https://github.com/KSXGitHub
on May 17, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-389818734
Klaus Meinhardt (@ajafff)https://github.com/ajafff
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on May 17, 2018https://github.com/microsoft/TypeScript/issues/24193#event-1632406439
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Jun 10, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-396075347
#24479https://github.com/microsoft/TypeScript/issues/24479
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Jun 10, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-396075365
https://github.com/AnyhowStep
AnyhowStephttps://github.com/AnyhowStep
on Jul 6, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-402920235
#25447https://github.com/microsoft/TypeScript/issues/25447
Playground Linkhttp://www.typescriptlang.org/play/#src=interface%20A%20%7B%0D%0A%20%20f%3F%3A%20number%3B%0D%0A%20%20bar%3A%20string%3B%20%0D%0A%7D%0D%0A%0D%0Ainterface%20B%20%7B%0D%0A%20%20f%3A%20number%3B%20%0D%0A%7D%0D%0Adeclare%20const%20x%3A%20A%20%7C%20B%3B%0D%0Aif%20(x.f%20%3D%3D%20undefined)%20%7B%0D%0A%20%20%2F%2FExpected%3A%0D%0A%20%20%2F%2F'x'%20is%20narrowed%20to%20type%20'A'%0D%0A%20%20%2F%2FActual%3A%0D%0A%20%20%2F%2FProperty%20'bar'%20does%20not%20exist%20on%20type%20'A%20%7C%20B'.%0D%0A%20%20%2F%2FProperty%20'bar'%20does%20not%20exist%20on%20type%20'B'.%0D%0A%20%20console.log(x.bar)%3B%0D%0A%7D%20
https://github.com/simonbuchan
Simon Buchan (simonbuchan)https://github.com/simonbuchan
on Jul 24, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-407244923
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Aug 23, 2018https://github.com/microsoft/TypeScript/issues/24193#event-1804323627
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Futurehttps://github.com/microsoft/TypeScript/milestone/29
on Aug 23, 2018https://github.com/microsoft/TypeScript/issues/24193#event-1804323654
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
help wantedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22help%20wanted%22
on Aug 23, 2018https://github.com/microsoft/TypeScript/issues/24193#event-1804323782
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 23, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-415287572
https://github.com/jack-williams
Jack Williams (jack-williams)https://github.com/jack-williams
on Oct 9, 2018https://github.com/microsoft/TypeScript/issues/24193#issuecomment-428199304
#27631https://github.com/microsoft/TypeScript/pull/27631
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
on Oct 10, 2018https://github.com/microsoft/TypeScript/issues/24193#event-1896833538
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#27695https://github.com/microsoft/TypeScript/pull/27695
on Oct 15, 2018https://github.com/microsoft/TypeScript/issues/24193#event-1905097192
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
Futurehttps://github.com/microsoft/TypeScript/milestone/29
TypeScript 3.2https://github.com/microsoft/TypeScript/milestone/77
on Nov 27, 2018https://github.com/microsoft/TypeScript/issues/24193#event-1990387865
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/24193
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/24193
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 3.2https://github.com/microsoft/TypeScript/milestone/77
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.