DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)

TS has pretty good types and can do exhaustive pattern matching. Here’s an example of doing so with classes and instanceof - smth I didn’t think was possible (and neither did my AI).

See the full code and run it - [TS Playground](https://www.typescriptlang.org/play/?ssl=63&ssc=2&pln=32&pc=1#code/MYGwhgzhAEAiD2BzaBvAUNaEAOBTMA1gBQCUqGm0w8AdhPCLgHQhJEBEARmAE4HskA3BQC+aMWlCQYAYTAAXcphz5iZdJSq16jFm3YBZXAHd4A4ZjESpUaAGUahXEqx5CpF5mp0GzVog4ACQBLKHNRcTQ0ADMAVxpgeWDaaABbBWAAC2CaAJzsWPkALjgkaAAfaDlFSocnEhKAN3hggBMXYOiifMLoHIh5MATceGjSxHUKTB75JhV3EinoHlx5WJ4aC2gRaFwQCGdO7poCxX7B4dGqhUnNGbm3NSWVtY2tiS9tRVwAD0ywWIDYKNXAlGi4EE8aAAXj6J0KW28Oj8bAABnZMvBYiB2jR4IpEKtoJl…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help