René's URL Explorer Experiment


Title: Indirect type narrowing via `const` · Issue #12184 · microsoft/TypeScript · GitHub

Open Graph Title: Indirect type narrowing via `const` · Issue #12184 · microsoft/TypeScript

X Title: Indirect type narrowing via `const` · Issue #12184 · microsoft/TypeScript

Description: TypeScript Version: 2.0.3 Code interface Square { kind: "square"; size: number; } interface Rectangle { kind: "rectangle"; width: number; height: number; } type Shape = Square | Rectangle; function area(s: Shape) { // // Doesn’t compile:...

Open Graph Description: TypeScript Version: 2.0.3 Code interface Square { kind: "square"; size: number; } interface Rectangle { kind: "rectangle"; width: number; height: number; } type Shape = Square | Rectangle; function...

X Description: TypeScript Version: 2.0.3 Code interface Square { kind: "square"; size: number; } interface Rectangle { kind: "rectangle"; width: number; height: number; } type Shape = Square |...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Indirect type narrowing via `const`","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\r\n**TypeScript Version:**  2.0.3\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface Square {\r\n    kind: \"square\";\r\n    size: number;\r\n}\r\n\r\ninterface Rectangle {\r\n    kind: \"rectangle\";\r\n    width: number;\r\n    height: number;\r\n}\r\n\r\ntype Shape = Square | Rectangle;\r\n\r\nfunction area(s: Shape) {\r\n\r\n    // // Doesn’t compile: Using a `const` as a type guard:\r\n    // // `error TS2339: Property 'size' does not exist on type 'Shape'.`\r\n\r\n    // const isSquare = s.kind === 'square';\r\n    // if (isSquare) {\r\n    //     return s.size * s.size;\r\n    // }\r\n\r\n    // // `s` is not narrowed to type `Rectangle`\r\n\r\n    // Compiles: Directly using `s` in the type guard:\r\n    if (s.kind === 'square') {\r\n        return s.size * s.size; // `s` has type `Square`\r\n    }\r\n\r\n    // `s` is narrowed to type `Rectangle`\r\n\r\n    return s.width * s.height;\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`s`’s type can be narrowed indirectly via a `const`.\r\n\r\n**Actual behavior:** \r\n\r\n`s`’s type can only be narrowed via direct access.","author":{"url":"https://github.com/gasi","@type":"Person","name":"gasi"},"datePublished":"2016-11-11T22:29:56Z","url":"https://github.com/microsoft/TypeScript/issues/12184"}

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:ff8d22c9-9cca-ae4c-c79f-3e45d6b1279d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9994:10338A:AD3859:EE1891:6B047C4D
html-safe-nonce6259cf0fe835c7899a5be1a0edb90a20fe906f04baa9c4f503378da1e6d930d3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTk0OjEwMzM4QTpBRDM4NTk6RUUxODkxOjZCMDQ3QzREIiwidmlzaXRvcl9pZCI6Ijg0MDAwNDc0NDEwMjk5MjE4NjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace10c9e1ec8cc504bdf001703c03a650bac13f4a556bf7e60c71a0357496d7b45
hovercard-subject-tagissue:188865199
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/12184/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1c3e7f0348329e3551bb9a40c195048fc2c45a1e99a8905729846350cc292353/microsoft/TypeScript/issues/12184
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1c3e7f0348329e3551bb9a40c195048fc2c45a1e99a8905729846350cc292353/microsoft/TypeScript/issues/12184
og:image:altTypeScript Version: 2.0.3 Code interface Square { kind: "square"; size: number; } interface Rectangle { kind: "rectangle"; width: number; height: number; } type Shape = Square | Rectangle; function...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegasi
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/12184#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F12184
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%2F12184
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/12184
Reloadhttps://github.com/microsoft/TypeScript/issues/12184
Reloadhttps://github.com/microsoft/TypeScript/issues/12184
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/12184
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/12184
#44730https://github.com/microsoft/TypeScript/pull/44730
Indirect type narrowing via consthttps://github.com/microsoft/TypeScript/issues/12184#top
#44730https://github.com/microsoft/TypeScript/pull/44730
https://github.com/ahejlsberg
RevisitAn issue worth coming back tohttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Revisit%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 4.4.0 (Beta)https://github.com/microsoft/TypeScript/milestone/141
https://github.com/gasi
Daniel Gasienica (gasi)https://github.com/gasi
on Nov 11, 2016https://github.com/microsoft/TypeScript/issues/12184#issue-188865199
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on Nov 13, 2016https://github.com/microsoft/TypeScript/issues/12184#event-856907787
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Nov 13, 2016https://github.com/microsoft/TypeScript/issues/12184#issuecomment-260162839
https://github.com/gasi
Daniel Gasienica (gasi)https://github.com/gasi
on Nov 14, 2016https://github.com/microsoft/TypeScript/issues/12184#issuecomment-260483661
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
https://github.com/electricessence
electricessencehttps://github.com/electricessence
on Nov 17, 2016https://github.com/microsoft/TypeScript/issues/12184#issuecomment-261318931
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
RevisitAn issue worth coming back tohttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Revisit%22
on Mar 15, 2018https://github.com/microsoft/TypeScript/issues/12184#event-1524061688
https://github.com/shayded-exe
SHAYDED (shayded-exe)https://github.com/shayded-exe
on Aug 1, 2019https://github.com/microsoft/TypeScript/issues/12184#issuecomment-517434407
https://github.com/akomm
Andriy Komm (akomm)https://github.com/akomm
on Nov 21, 2019https://github.com/microsoft/TypeScript/issues/12184#issuecomment-557126462
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
thishttps://github.com/microsoft/TypeScript/issues/32639
Daniel Gasienica (@gasi)https://github.com/gasi
https://github.com/kamilic
kamilic (kamilic)https://github.com/kamilic
on May 31, 2020https://github.com/microsoft/TypeScript/issues/12184#issuecomment-636417680
https://github.com/ronaldruzicka
Ronald Ruzicka (ronaldruzicka)https://github.com/ronaldruzicka
on Oct 1, 2020https://github.com/microsoft/TypeScript/issues/12184#issuecomment-702108352
https://tinyurl.com/y7nrawkhhttps://tinyurl.com/y7nrawkh
https://github.com/ronaldruzicka
Ronald Ruzicka (ronaldruzicka)https://github.com/ronaldruzicka
on Oct 1, 2020https://github.com/microsoft/TypeScript/issues/12184#issuecomment-702112581
https://github.com/amannn
Jan Amann (amannn)https://github.com/amannn
on Oct 1, 2020https://github.com/microsoft/TypeScript/issues/12184#issuecomment-702142967
similar onehttps://github.com/microsoft/TypeScript/issues/39996
https://github.com/maraisr
Marais Rossouw (maraisr)https://github.com/maraisr
on Nov 23, 2020https://github.com/microsoft/TypeScript/issues/12184#issuecomment-732103607
https://github.com/AlCalzone
AlCalzonehttps://github.com/AlCalzone
on Dec 11, 2020https://github.com/microsoft/TypeScript/issues/12184#issuecomment-743199522
https://github.com/ExE-Boss
ExE Boss (ExE-Boss)https://github.com/ExE-Boss
on Dec 13, 2020https://github.com/microsoft/TypeScript/issues/12184#issuecomment-743923713
https://github.com/monfera
Robert Monfera (monfera)https://github.com/monfera
on Jan 21, 2021https://github.com/microsoft/TypeScript/issues/12184#issuecomment-764549937
Ronald Ruzicka (@ronaldruzicka)https://github.com/ronaldruzicka
AlCalzonehttps://github.com/AlCalzone
Daniel Gasienica (@gasi)https://github.com/gasi
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
https://github.com/Nokel81
Sebastian Malton (Nokel81)https://github.com/Nokel81
on Jan 22, 2021https://github.com/microsoft/TypeScript/issues/12184#issuecomment-765644043
AlCalzonehttps://github.com/AlCalzone
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jan 22, 2021https://github.com/microsoft/TypeScript/issues/12184#issuecomment-765654708
#391https://github.com/microsoft/TypeScript/issues/391
https://github.com/Nokel81
Sebastian Malton (Nokel81)https://github.com/Nokel81
on Jan 22, 2021https://github.com/microsoft/TypeScript/issues/12184#issuecomment-765656896
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
#24865https://github.com/microsoft/TypeScript/issues/24865
https://github.com/monfera
Robert Monfera (monfera)https://github.com/monfera
on Jan 22, 2021https://github.com/microsoft/TypeScript/issues/12184#issuecomment-765734075
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
AlCalzonehttps://github.com/AlCalzone
imperfect userland asks on ghhttps://twitter.com/MissReeeves/status/1313587567137370113
https://github.com/AuthorProxy
Alex Kostyukov (AuthorProxy)https://github.com/AuthorProxy
on Jun 1, 2021https://github.com/microsoft/TypeScript/issues/12184#issuecomment-852037941
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Jun 24, 2021https://github.com/microsoft/TypeScript/issues/12184#event-4936108737
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Jun 24, 2021https://github.com/microsoft/TypeScript/issues/12184#issuecomment-867928408
#44730https://github.com/microsoft/TypeScript/pull/44730
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
TypeScript 4.4.0 (Beta)https://github.com/microsoft/TypeScript/milestone/141
on Jun 25, 2021https://github.com/microsoft/TypeScript/issues/12184#event-4941957556
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#44730https://github.com/microsoft/TypeScript/pull/44730
on Jun 25, 2021https://github.com/microsoft/TypeScript/issues/12184#event-4941961240
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/12184
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/12184
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
RevisitAn issue worth coming back tohttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Revisit%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 4.4.0 (Beta)https://github.com/microsoft/TypeScript/milestone/141
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.