(no title)
thewix | 2 years ago
For example, if `type ShoppingCart = EmptyCart | LoadedCart` then `addToCart` is just a map from `ShoppingCart` to `LoadedCart`. It makes invalid states impossible to represent and flows become clearer. Add in good FP and composition becomes easier.
tacotacotaco|2 years ago
Several of the terrible typescript projects I referred to still used property values to represent state (like your example). Just because every definition has a type doesn’t make it good code. Shitty typed code is still shitty code. My concern is that many in our industry conflate typescript with quality and stop there.
dylanowen|2 years ago
IshKebab|2 years ago
Yes, but it's at least code you can understand, navigate and refactor.