René's URL Explorer Experiment


Title: Type narrowing with foo.constructor · Issue #16035 · microsoft/TypeScript · GitHub

Open Graph Title: Type narrowing with foo.constructor · Issue #16035 · microsoft/TypeScript

X Title: Type narrowing with foo.constructor · Issue #16035 · microsoft/TypeScript

Description: TypeScript Version: 2.3.1 Code class FooTask { foo: number; } class BarTask { bar: number; } type taskType = FooTask|BarTask; function createEvent(task: taskType) { if (task instanceof FooTask) { task.foo; // Works. } switch (task.constr...

Open Graph Description: TypeScript Version: 2.3.1 Code class FooTask { foo: number; } class BarTask { bar: number; } type taskType = FooTask|BarTask; function createEvent(task: taskType) { if (task instanceof FooTask) { t...

X Description: TypeScript Version: 2.3.1 Code class FooTask { foo: number; } class BarTask { bar: number; } type taskType = FooTask|BarTask; function createEvent(task: taskType) { if (task instanceof FooTask) { t...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type narrowing with foo.constructor","articleBody":"**TypeScript Version:**  2.3.1\r\n\r\n**Code**\r\n\r\n```ts\r\nclass FooTask {\r\n  foo: number;\r\n}\r\n\r\nclass BarTask {\r\n  bar: number;\r\n}\r\n\r\ntype taskType = FooTask|BarTask;\r\n\r\nfunction createEvent(task: taskType) {\r\n  if (task instanceof FooTask) {\r\n    task.foo; // Works.\r\n  }\r\n\r\n  switch (task.constructor) {\r\n    case FooTask:\r\n      task.foo; // Fails.\r\n  }\r\n}\r\n```\r\n\r\nIt would be nice if the second worked like the first; narrowed the type of `task` appropriately.","author":{"url":"https://github.com/calebegg","@type":"Person","name":"calebegg"},"datePublished":"2017-05-23T18:19:36Z","url":"https://github.com/microsoft/TypeScript/issues/16035"}

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:415ddeea-4e37-f19a-33dc-e8f0a20a1a9f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id82B0:38C5CF:D91538:117323E:6B00F19C
html-safe-nonce1dbadc7e2790407578cc15b4aa731a0ff6b3b06f4d61cff22f8519d5506fe9fb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkIwOjM4QzVDRjpEOTE1Mzg6MTE3MzIzRTo2QjAwRjE5QyIsInZpc2l0b3JfaWQiOiIxMDkyNjU5ODQxNDUxMjU3ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacde803433bdef5b2af58b6a0c52c7c264362d675f7d25967535b1c62a7f5e179e
hovercard-subject-tagissue:230799628
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/16035/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1ed69dc1d7867401f265ecb3cf9c473f697cac22733add8fa647c431eeaaf927/microsoft/TypeScript/issues/16035
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1ed69dc1d7867401f265ecb3cf9c473f697cac22733add8fa647c431eeaaf927/microsoft/TypeScript/issues/16035
og:image:altTypeScript Version: 2.3.1 Code class FooTask { foo: number; } class BarTask { bar: number; } type taskType = FooTask|BarTask; function createEvent(task: taskType) { if (task instanceof FooTask) { t...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecalebegg
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
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
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/16035#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F16035
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%2F16035
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/16035
Reloadhttps://github.com/microsoft/TypeScript/issues/16035
Reloadhttps://github.com/microsoft/TypeScript/issues/16035
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests308 (308)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/16035
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/16035
Type narrowing with foo.constructorhttps://github.com/microsoft/TypeScript/issues/16035#top
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/calebegg
Caleb Eggensperger (calebegg)https://github.com/calebegg
on May 23, 2017https://github.com/microsoft/TypeScript/issues/16035#issue-230799628
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on May 23, 2017https://github.com/microsoft/TypeScript/issues/16035#event-1094357508
https://github.com/glebm
Gleb Mazovetskiy (glebm)https://github.com/glebm
on Oct 21, 2017https://github.com/microsoft/TypeScript/issues/16035#issuecomment-338425335
#3841https://github.com/microsoft/TypeScript/issues/3841
https://github.com/glebm
Gleb Mazovetskiy (glebm)https://github.com/glebm
on Oct 27, 2017https://github.com/microsoft/TypeScript/issues/16035#issuecomment-339901596
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Oct 27, 2017https://github.com/microsoft/TypeScript/issues/16035#issuecomment-340018020
https://github.com/ExE-Boss
ExE Boss (ExE-Boss)https://github.com/ExE-Boss
on Aug 28, 2020https://github.com/microsoft/TypeScript/issues/16035#issuecomment-682272092
https://github.com/karol-majewski
Karol Majewski (karol-majewski)https://github.com/karol-majewski
on Nov 3, 2020https://github.com/microsoft/TypeScript/issues/16035#issuecomment-720795983
TypeScript Playgroundhttps://tsplay.dev/nmqoZw
https://github.com/murbanowicz
Marek (murbanowicz)https://github.com/murbanowicz
on Apr 13, 2021https://github.com/microsoft/TypeScript/issues/16035#issuecomment-818467737
https://github.com/ukstv
Sergey Ukustov (ukstv)https://github.com/ukstv
on Sep 7, 2022https://github.com/microsoft/TypeScript/issues/16035#issuecomment-1239609044
https://github.com/matthew-dean
Matthew Dean (matthew-dean)https://github.com/matthew-dean
on May 5, 2023https://github.com/microsoft/TypeScript/issues/16035#issuecomment-1536347922
https://github.com/mackuba
Kuba Suder (mackuba)https://github.com/mackuba
on May 20, 2024https://github.com/microsoft/TypeScript/issues/16035#issuecomment-2121088855
https://github.com/Lukortech
Lukortech (Lukortech)https://github.com/Lukortech
on Jan 25, 2025https://github.com/microsoft/TypeScript/issues/16035#issuecomment-2613748786
https://private-user-images.githubusercontent.com/26508593/406635759-17d9c1de-287b-4420-a13a-42499add9a8c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUyMjQyNjUsIm5iZiI6MTc5NTIyMzk2NSwicGF0aCI6Ii8yNjUwODU5My80MDY2MzU3NTktMTdkOWMxZGUtMjg3Yi00NDIwLWExM2EtNDI0OTlhZGQ5YThjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTIxVDAxMTkyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZkN2I0ZDUxYzJjMWI4N2Q3OTkwZjc2ZTdhYjcxNWY3OTMyNmY4ZjI4MDVjNDkzYzI4Y2FhYmRhZGYyNjAzNjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.BfpODrePrGUeeWyDVcYCqLMNi9A-4VPvjRIM3hb2xLg
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/16035
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/16035
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%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.