Give me a Break. I'm still learning!
Hey everyone. I'm back.
And, yeah, I'm still making n00b TypeScript mistakes 😢
But luckily I've...
For further actions, you may consider blocking this person and/or reporting abuse
This works for basic exhaustiveness checks, but when things are more complicated (or depend on two things, e.g. a
boolean
calledisSubscribed
in combination with an optional plan tier) we've found thatts-pattern
is a great library for handling that kind of stuff in a way where the compiler still gives you an exhaustiveness check on your enum, for example.Also, it allows you to disambiguate arguments, variables, API responses, etc. at run-time structurally (similarly to the way TS does it at design time) which is pretty neat. And you don't have to go full nerd and really understand what things like "contravariance" mean!
oh wow. nice! I'll have to check this out.
Love this series!
Keep em coming 😄
Glad you like it :)
I love this "Watch me learn TypeScript" series, and a relaxed tone you use with it. Plus I also learn stuff :)
It's never too late to teach an old dog new tricks 🐶
Very cool idea. Actually leveraging your lack of understanding of something to sell it and also learn at the same time.
One convention I'd like to mention is that for your PaymentPlanId enum, it is commonly assumed that ids represent a non limited identifier which is typically not a good idea for an enum. A more common approach to indicate that an identifier is limited to a short list that will likely not change much is Code. So, it might be better to call it PaymentPlanCode.
Again, this is just a common convention. There is no rule that says you must do it this way, however, you'll often find that conventions like these help convey meaning without bloating code.
ah nice, that makes sense. thanks for the tip!
This series is a delight to read and is also teaching me a lot. I really appreciate the examples with use-cases 😊🤌
thanks. glad you like it!
Thanks for mentioning Wasp. I'm doing some frameworks try out this time.
Great stuff!
thanks!