René's URL Explorer Experiment


Title: Support user-defined type guard functions · Issue #1007 · microsoft/TypeScript · GitHub

Open Graph Title: Support user-defined type guard functions · Issue #1007 · microsoft/TypeScript

X Title: Support user-defined type guard functions · Issue #1007 · microsoft/TypeScript

Description: We currently only support some baked-in forms of type checking for type guards -- typeof and instanceof. In many cases, users will have their own functions that can provide run-time type information. Proposal: a new syntax, valid only in...

Open Graph Description: We currently only support some baked-in forms of type checking for type guards -- typeof and instanceof. In many cases, users will have their own functions that can provide run-time type informatio...

X Description: We currently only support some baked-in forms of type checking for type guards -- typeof and instanceof. In many cases, users will have their own functions that can provide run-time type informatio...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support user-defined type guard functions","articleBody":"We currently only support some baked-in forms of type checking for type guards -- `typeof` and `instanceof`. In many cases, users will have their own functions that can provide run-time type information.\n\nProposal: a new syntax, valid only in return type annotations, of the form `x is T` where `x` is a declared parameter in the signature, or `this`, and `T` is any type. This type is actually considered as `boolean`, but \"lights up\" type guards. Examples:\n\n``` ts\nfunction isCat(a: Animal): a is Cat {\n  return a.name === 'kitty';\n}\n\nvar x: Animal;\nif(isCat(x)) {\n  x.meow(); // OK, x is Cat in this block\n}\n\nclass Node {\n  isLeafNode(): this is LeafNode { throw new Error('abstract'); }\n}\nclass ParentNode extends Node {\n  isLeafNode(): this is LeafNode { return false; }\n}\nclass LeafNode extends Node {\n  isLeafNode(): this is LeafNode { return true; }\n}\nvar someNode: LeafNode|ParentNode;\nif(someNode.isLeafNode()) {\n  // someNode: LeafNode in this block\n}\n```\n\nThe forms `if(userCheck([other args,] expr [, other args])) {` and `if(expr.userCheck([any args]))` would apply the type guard to `expr` the same way that `expr instanceof t` and `typeof expr === 'literal'` do today.\n","author":{"url":"https://github.com/RyanCavanaugh","@type":"Person","name":"RyanCavanaugh"},"datePublished":"2014-10-30T21:05:34Z","url":"https://github.com/microsoft/TypeScript/issues/1007"}

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:897341b1-044a-e389-a504-17091b139e54
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD8DA:60624:669A:8AF8:6AFBF420
html-safe-nonce2f2f7e76e5228409f1bc20e8bb9891e7ba73f08be703aef837e0ca91e148bcb5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOERBOjYwNjI0OjY2OUE6OEFGODo2QUZCRjQyMCIsInZpc2l0b3JfaWQiOiI0MjIwMDI4NjgxNjE4Njg4MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaccf169fc54ccffe512aecc58db8f5047db98c62fb86d04f089eea5f6d6301787d
hovercard-subject-tagissue:47327525
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/1007/issue_layout
twitter:imagehttps://opengraph.githubassets.com/dc3cac701b87337d8870c48cda1b4c3d2e13d42d4549e9ec425aa396a7851f7c/microsoft/TypeScript/issues/1007
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/dc3cac701b87337d8870c48cda1b4c3d2e13d42d4549e9ec425aa396a7851f7c/microsoft/TypeScript/issues/1007
og:image:altWe currently only support some baked-in forms of type checking for type guards -- typeof and instanceof. In many cases, users will have their own functions that can provide run-time type informatio...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameRyanCavanaugh
hostnamegithub.com
expected-hostnamegithub.com
Nonefa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f
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
releaseb3b5633a74535d9c23385512d534c66c8fde1907
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/1007#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F1007
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%2F1007
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/1007
Reloadhttps://github.com/microsoft/TypeScript/issues/1007
Reloadhttps://github.com/microsoft/TypeScript/issues/1007
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests335 (335)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/pulse
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/1007
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/1007
Support user-defined type guard functionshttps://github.com/microsoft/TypeScript/issues/1007#top
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
Community (deprecated)https://github.com/microsoft/TypeScript/milestone/2
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Oct 30, 2014https://github.com/microsoft/TypeScript/issues/1007#issue-47327525
Nexthttps://github.com/microsoft/TypeScript/issues/1007?timeline_page=1
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
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 Oct 30, 2014https://github.com/microsoft/TypeScript/issues/1007#event-186223791
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Oct 30, 2014https://github.com/microsoft/TypeScript/issues/1007#event-186223876
https://github.com/Nevor
Roven Lamar Gabriel (Nevor)https://github.com/Nevor
on Oct 31, 2014https://github.com/microsoft/TypeScript/issues/1007#issuecomment-61239389
#1003https://github.com/microsoft/TypeScript/issues/1003
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Oct 31, 2014https://github.com/microsoft/TypeScript/issues/1007#issuecomment-61241232
https://github.com/Nevor
Roven Lamar Gabriel (Nevor)https://github.com/Nevor
on Oct 31, 2014https://github.com/microsoft/TypeScript/issues/1007#issuecomment-61250930
https://github.com/bgever
Bart Verkoeijen (bgever)https://github.com/bgever
on Nov 20, 2014https://github.com/microsoft/TypeScript/issues/1007#issuecomment-63756880
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Nov 20, 2014https://github.com/microsoft/TypeScript/issues/1007#issuecomment-63818142
Bart Verkoeijen (@bgever)https://github.com/bgever
https://github.com/Arnavion
Arnav Singh (Arnavion)https://github.com/Arnavion
on Dec 10, 2014https://github.com/microsoft/TypeScript/issues/1007#issuecomment-66410207
https://github.com/awerlang
André Werlang (awerlang)https://github.com/awerlang
on Jan 26, 2015https://github.com/microsoft/TypeScript/issues/1007#issuecomment-71511862
Arnav Singh (@Arnavion)https://github.com/Arnavion
https://github.com/Arnavion
Arnav Singh (Arnavion)https://github.com/Arnavion
on Jan 26, 2015https://github.com/microsoft/TypeScript/issues/1007#issuecomment-71522454
André Werlang (@awerlang)https://github.com/awerlang
https://github.com/awerlang
André Werlang (awerlang)https://github.com/awerlang
on Jan 26, 2015https://github.com/microsoft/TypeScript/issues/1007#issuecomment-71524926
Arnav Singh (@Arnavion)https://github.com/Arnavion
#1427https://github.com/microsoft/TypeScript/issues/1427
https://github.com/Arnavion
Arnav Singh (Arnavion)https://github.com/Arnavion
on Jan 26, 2015https://github.com/microsoft/TypeScript/issues/1007#issuecomment-71553484
#1427https://github.com/microsoft/TypeScript/issues/1427
https://github.com/mintern
Brandon Mintern (mintern)https://github.com/mintern
on Feb 17, 2015https://github.com/microsoft/TypeScript/issues/1007#issuecomment-74661476
Entryhttps://developer.mozilla.org/en-US/docs/Web/API/Entry
File System APIhttps://developer.mozilla.org/en-US/docs/WebGuide/API/File_System
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Accepting PRshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Accepting%20PRs%22
on Apr 27, 2015https://github.com/microsoft/TypeScript/issues/1007#event-291364539
https://github.com/shelby3
shelby3https://github.com/shelby3
on Sep 12, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246458721
spion (@spion)https://github.com/spion
global symbol registryhttp://www.2ality.com/2014/12/es6-symbols.html#crossing_realms_with_symbols
probabilistically sure of no collisionshttp://preshing.com/20110504/hash-collision-probabilities/
https://github.com/spion
spion (spion)https://github.com/spion
on Sep 12, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246505252
This is not merely a theoretical concernhttps://github.com/petkaantonov/bluebird/issues/990
https://github.com/yortus
Troy Gerwien (yortus)https://github.com/yortus
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246553334
Symbol.hasInstancehttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance
https://github.com/eggers
Jacob Eggers (eggers)https://github.com/eggers
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246565959
shelby3https://github.com/shelby3
Troy Gerwien (@yortus)https://github.com/yortus
https://github.com/shelby3
shelby3https://github.com/shelby3
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246691835
spion (@spion)https://github.com/spion
https://github.com/shelby3
shelby3https://github.com/shelby3
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246703136
Jacob Eggers (@eggers)https://github.com/eggers
three different possible suggestionshttps://github.com/Microsoft/TypeScript/issues/1007#issuecomment-246267371
use purely structural matching for the user guardhttps://github.com/Microsoft/TypeScript/issues/1007#issuecomment-246318431
Troy Gerwien (@yortus)https://github.com/yortus
https://github.com/shelby3
shelby3https://github.com/shelby3
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246707622
Aluan Haddad (@aluanhaddad)https://github.com/aluanhaddad
may become much more reliablehttps://github.com/Microsoft/TypeScript/issues/1007#issuecomment-246553334
https://github.com/eggers
Jacob Eggers (eggers)https://github.com/eggers
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246749303
shelby3https://github.com/shelby3
https://github.com/shelby3
shelby3https://github.com/shelby3
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246859426
Jacob Eggers (@eggers)https://github.com/eggers
https://github.com/eggers
Jacob Eggers (eggers)https://github.com/eggers
on Sep 13, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246862789
shelby3https://github.com/shelby3
https://github.com/shelby3
shelby3https://github.com/shelby3
on Sep 14, 2016https://github.com/microsoft/TypeScript/issues/1007#issuecomment-246921106
Jacob Eggers (@eggers)https://github.com/eggers
#1007https://github.com/microsoft/TypeScript/issues/1007
#1007https://github.com/microsoft/TypeScript/issues/1007
https://github.com/nickredmark
Nick Redmark (nickredmark)https://github.com/nickredmark
on Oct 13, 2017https://github.com/microsoft/TypeScript/issues/1007#issuecomment-336400242
https://github.com/kitsonk
Kitson Kelly (kitsonk)https://github.com/kitsonk
on Oct 13, 2017https://github.com/microsoft/TypeScript/issues/1007#issuecomment-336435046
StackOverflowhttp://stackoverflow.com/questions/ask?tags=typescript
Gitter.imhttps://gitter.im/Microsoft/TypeScript
https://github.com/yortus
Troy Gerwien (yortus)https://github.com/yortus
on Oct 13, 2017https://github.com/microsoft/TypeScript/issues/1007#issuecomment-336436865
nmarohttps://github.com/nmaro
#8655https://github.com/microsoft/TypeScript/issues/8655
microsofthttps://github.com/microsoft
on Jun 18, 2018https://github.com/microsoft/TypeScript/issues/1007#event-1686910903
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/1007
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/1007
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
Community (deprecated)https://github.com/microsoft/TypeScript/milestone/2
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.