Re:TypeScript’s quirks: How inconsistencies make the languag...
by firethief on Saturday February 01, 2020 @11:32AM
(#22211379)
Have you considered OCaml with BuckleScript or js_of_ocaml? The language that inspired Rust's nods to FP can be compiled to mostly-idiomatic Javascript.
Re:TypeScript’s quirks: How inconsistencies make the languag...
by Fannon on Sunday February 02, 2020 @03:25AM
(#22215862)
Pattern matching seems to be a current proposal, also driven by Microsoft: https://github.com/tc39/proposal-pattern-matching
Re:TypeScript’s quirks: How inconsistencies make the languag...
by Shacklz on Sunday February 02, 2020 @03:22AM
(#22215855)
Pattern matching is definitely something I also miss. For input validation and Optional/Either types, io-ts/fp-ts (https://github.com/gcanti/io-ts) fulfill my needs perfectly, especially io-ts is something I can't recommend enough. Saved me so many headaches from sudden breaking changes in APIs we consume.
However sometimes I kinda miss some functional stuff that you can for example find in Scala or Rust, like pattern matching. Specifically, we've had experience using/developing an input validation library for the backend in Typescript (https://github.com/StrontiumJS/Framework/) that is composable and also returns the correct type in one go. We used a lot of try catches for that, but that makes validation slow. So we started using "maybe promises" which are similar to Scala's Futures with Success/Failure. But the fact you don't have pattern matching in Typescript like in Scala makes it a bit ugly.