René's URL Explorer Experiment


Title: Pattern Matching Support · Issue #165 · microsoft/TypeScript · GitHub

Open Graph Title: Pattern Matching Support · Issue #165 · microsoft/TypeScript

X Title: Pattern Matching Support · Issue #165 · microsoft/TypeScript

Description: I've seen some short notions about pattern matching on code plex, but no serious discussions around it. As I'm a big fan of it, I've written up some small examples on how I think pattern matching could look in TypeScript. This is by far ...

Open Graph Description: I've seen some short notions about pattern matching on code plex, but no serious discussions around it. As I'm a big fan of it, I've written up some small examples on how I think pattern matching c...

X Description: I've seen some short notions about pattern matching on code plex, but no serious discussions around it. As I'm a big fan of it, I've written up some small examples on how I think patter...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pattern Matching Support","articleBody":"I've seen some short notions about pattern matching on code plex, but no serious discussions around it. As I'm a big fan of it, I've written up some small examples on how I think pattern matching could look in TypeScript.\n\nThis is by far no complete specification, just some ideas that I want to bring forward and have a little discussion around.\n## Function Overloading\n\n``` ts\n// Pattern matching on functions\n\nfunction pickCard {\n  (x: {suit: string; card: number; }[]): number {\n\n    var pickedCard = Math.floor(Math.random() * x.length);\n    return pickedCard;  \n\n  }\n  (x: number): {suit: string; card: number; } {\n\n    var pickedSuit = Math.floor(x / 13);\n    return { suit: suits[pickedSuit], card: x % 13 };\n\n  }\n} \n```\n\n``` js\n// Translation of functions.ts using sparkler\n// https://github.com/natefaubion/sparkler\n\nfunction pickCard(x) {\n  [...{ suit @ String, card @ number }] =>  {\n    var pickedCard = Math.floor(Math.random() * x.length);\n    return pickedCard;  \n  }\n  x @ Number => {\n    var pickedSuit = Math.floor(x / 13);\n    return { suit: suits[pickedSuit], card: x % 13 };\n  }\n} \n```\n## `Match` statement\n\n``` ts\n// Pattern matching using match\n\nfunction whoami (x: any): string {\n\n  match x {\n    case { name: string, type: 'person' }: \n        return 'Person: ' + name;\n\n    case { name: string, type: 'animal' }: \n        return 'Animal: ' + name;\n\n    default: \n        return 'Unkown you';\n  }\n} \n```\n\n``` js\n// Pattern matching using match translated\n\nfunction whoami (x) {\n\n  match x {\n    case { name @ String, type: 'person' }: \n        return 'Person: ' + name;\n\n    case { name @ String, type: 'animal' }: \n        return 'Animal: ' + name;\n\n    default: \n        return 'Unkown you';\n  }\n\n} \n```\n","author":{"url":"https://github.com/dignifiedquire","@type":"Person","name":"dignifiedquire"},"datePublished":"2014-07-21T19:42:28Z","url":"https://github.com/microsoft/TypeScript/issues/165"}

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:c4568ded-9d6c-a603-fbfc-5b138afe1612
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA994:2463BD:2A568AA:3611679:6B019C0B
html-safe-noncef2d40d7ce3084cbea5d773225e2c4ad0db525cc0732a23f1bcff11989e9df763
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTk0OjI0NjNCRDoyQTU2OEFBOjM2MTE2Nzk6NkIwMTlDMEIiLCJ2aXNpdG9yX2lkIjoiNjc3OTkwMzg1OTA2NzI5Njc4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2b1bd0a780942b00940e3d2e053d6cdba32bd6c6d2adc43658d710a6b06547f1
hovercard-subject-tagissue:38337284
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/165/issue_layout
twitter:imagehttps://opengraph.githubassets.com/85345a25aebbdf61024ccebb50cbbaf6c491ebcf7654ea62a2e851bd8d75855f/microsoft/TypeScript/issues/165
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/85345a25aebbdf61024ccebb50cbbaf6c491ebcf7654ea62a2e851bd8d75855f/microsoft/TypeScript/issues/165
og:image:altI've seen some short notions about pattern matching on code plex, but no serious discussions around it. As I'm a big fan of it, I've written up some small examples on how I think pattern matching c...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedignifiedquire
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/Microsoft/TypeScript/issues/165#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FMicrosoft%2FTypeScript%2Fissues%2F165
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%2F165
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/165
Reloadhttps://github.com/Microsoft/TypeScript/issues/165
Reloadhttps://github.com/Microsoft/TypeScript/issues/165
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)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/165
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/165
Pattern Matching Supporthttps://github.com/microsoft/TypeScript/issues/165#top
Out of ScopeThis idea sits outside of the TypeScript language design constraintshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Out%20of%20Scope%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/dignifiedquire
Friedel Ziegelmayer (dignifiedquire)https://github.com/dignifiedquire
on Jul 21, 2014https://github.com/microsoft/TypeScript/issues/165#issue-38337284
Nexthttps://github.com/microsoft/TypeScript/issues/165?timeline_page=1
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jul 21, 2014https://github.com/microsoft/TypeScript/issues/165#issuecomment-49656086
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs Proposalhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Proposal%22
on Jul 21, 2014https://github.com/microsoft/TypeScript/issues/165#event-143877034
https://github.com/justinmchase
Justin Chase (justinmchase)https://github.com/justinmchase
on Jul 22, 2014https://github.com/microsoft/TypeScript/issues/165#issuecomment-49764068
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
http://www.tinlizzie.org/ometa-js/#Typecheckerhttp://www.tinlizzie.org/ometa-js/#Typechecker
https://github.com/AlexGalays
Alexandre Galays (AlexGalays)https://github.com/AlexGalays
on Mar 10, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-78020549
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 10, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-78131481
Alexandre Galays (@AlexGalays)https://github.com/AlexGalays
https://github.com/refi64
refi64https://github.com/refi64
on Aug 24, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-133984574
https://github.com/SamuelMarks
Samuel Marks (SamuelMarks)https://github.com/SamuelMarks
on Sep 21, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-141995640
https://github.com/dev-tim
Tim Zadorozhniy (dev-tim)https://github.com/dev-tim
on Oct 5, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-145506255
https://github.com/svanderbleek
Sandy Vanderbleek (svanderbleek)https://github.com/svanderbleek
on Oct 9, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-146795171
https://github.com/slavah
Slava H (slavah)https://github.com/slavah
on Oct 23, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-150683718
https://github.com/tejacques
Tom Jacques (tejacques)https://github.com/tejacques
on Dec 6, 2015https://github.com/microsoft/TypeScript/issues/165#issuecomment-162337687
#5916https://github.com/microsoft/TypeScript/issues/5916
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/felixSchl
Felix Schlitter (felixSchl)https://github.com/felixSchl
on Feb 11, 2016https://github.com/microsoft/TypeScript/issues/165#issuecomment-182663742
rusthttps://doc.rust-lang.org/book/match.html#matching-on-enums
haskellhttps://www.haskell.org/tutorial/patterns.html
purescripthttps://leanpub.com/purescript/read#leanpub-auto-case-expressions
fsharphttps://msdn.microsoft.com/en-us/library/dd233242.aspx
ocamlhttp://www2.lib.uchicago.edu/keith/ocaml-class/pattern-matching.html
scalahttp://docs.scala-lang.org/tutorials/tour/pattern-matching.html
https://github.com/tejacques
Tom Jacques (tejacques)https://github.com/tejacques
on Feb 11, 2016https://github.com/microsoft/TypeScript/issues/165#issuecomment-182665115
newman (@Zvxy)https://github.com/Zvxy
https://github.com/pelotom
Tom Crockett (pelotom)https://github.com/pelotom
on Nov 9, 2017https://github.com/microsoft/TypeScript/issues/165#issuecomment-343168937
Alexandre Galays (@AlexGalays)https://github.com/AlexGalays
https://github.com/AlexGalays
Alexandre Galays (AlexGalays)https://github.com/AlexGalays
on Nov 9, 2017https://github.com/microsoft/TypeScript/issues/165#issuecomment-343174529
Tom Crockett (@pelotom)https://github.com/pelotom
https://github.com/pelotom
Tom Crockett (pelotom)https://github.com/pelotom
on Nov 9, 2017https://github.com/microsoft/TypeScript/issues/165#issuecomment-343178214
https://github.com/xogeny
Michael Tiller (xogeny)https://github.com/xogeny
on Nov 9, 2017https://github.com/microsoft/TypeScript/issues/165#issuecomment-343257049
Alexandre Galays (@AlexGalays)https://github.com/AlexGalays
Tom Crockett (@pelotom)https://github.com/pelotom
a bunch of the boilerplatehttps://github.com/sgarciac/bombadil/blob/master/src/AST.ts
https://github.com/LayZeeDK
Lars Gyrup Brink Nielsen (LayZeeDK)https://github.com/LayZeeDK
on Jan 13, 2018https://github.com/microsoft/TypeScript/issues/165#issuecomment-357472504
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
take on this from Microsoft Build 2017https://channel9.msdn.com/Events/Build/2017/B8088
Amar Sood (@tekacs)https://github.com/tekacs
proposedhttps://github.com/Microsoft/TypeScript/issues/165#issuecomment-254564404
https://github.com/pelotom
Tom Crockett (pelotom)https://github.com/pelotom
on Jan 21, 2018https://github.com/microsoft/TypeScript/issues/165#issuecomment-359231706
Runtypes now supports pattern matchinghttps://github.com/pelotom/runtypes#pattern-matching
Asad Saeeduddin (@masaeedu)https://github.com/masaeedu
https://github.com/pelotom/runtypes/blob/a585fc813842ecd852d0ae07a4ff3673018e6c91/examples/src/shapes.ts#L11-L15https://github.com/pelotom/runtypes/blob/a585fc813842ecd852d0ae07a4ff3673018e6c91/examples/src/shapes.ts#L11-L15
https://github.com/dough654
Doug (dough654)https://github.com/dough654
on Feb 15, 2019https://github.com/microsoft/TypeScript/issues/165#issuecomment-464207946
https://github.com/just-chillin
Corrina Sivak (just-chillin)https://github.com/just-chillin
on May 1, 2020https://github.com/microsoft/TypeScript/issues/165#issuecomment-622292208
https://github.com/tc39/proposal-pattern-matchinghttps://github.com/tc39/proposal-pattern-matching
https://github.com/samhh
Sam A. Horvath-Hunt (samhh)https://github.com/samhh
on May 1, 2020https://github.com/microsoft/TypeScript/issues/165#issuecomment-622326431
https://github.com/Lonli-Lokli
Lonli-Loklihttps://github.com/Lonli-Lokli
on Jul 21, 2020https://github.com/microsoft/TypeScript/issues/165#issuecomment-661786121
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Out of ScopeThis idea sits outside of the TypeScript language design constraintshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Out%20of%20Scope%22
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Proposal%22
on Jul 21, 2020https://github.com/microsoft/TypeScript/issues/165#event-3572309846
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jul 21, 2020https://github.com/microsoft/TypeScript/issues/165#issuecomment-661993726
https://github.com/tc39/proposal-pattern-matchinghttps://github.com/tc39/proposal-pattern-matching
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 21, 2020https://github.com/microsoft/TypeScript/issues/165#event-3572316718
microsofthttps://github.com/microsoft
on Jul 21, 2020https://github.com/microsoft/TypeScript/issues/165#event-3572317499
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/165
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/165
Out of ScopeThis idea sits outside of the TypeScript language design constraintshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Out%20of%20Scope%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.