Thank you, Patrick, for this down-to-earth writeup. Nice balance of safety and practicality.
Without any return statements or other trickery, TS apparently does not do any exhaustive checks within switches
Yeah, the shortest way I've found was an IIFE and a type annotation, i.e.:
let foo: Foo = (() => switch (expr.kind) { case "doc": return ...; case "text": return ...; case "paragraph": return ...; })();
Workable, but much noisier than ReScript. And the lack of nested patterns is no fun. So that's 1 for ReScript :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you, Patrick, for this down-to-earth writeup. Nice balance of safety and practicality.
Yeah, the shortest way I've found was an IIFE and a type annotation, i.e.:
Workable, but much noisier than ReScript. And the lack of nested patterns is no fun. So that's 1 for ReScript :)