Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
proposal-record-tuple
ECMAScript proposal for the Record and Tuple value types. | Stage 2: it will change!
Is there a way to make the compiler aware that it's running in Node? I did set the target according to the Node target mapping.
Checkout fawait. It helps a bit. Not with typing the error, but it does help
Node fs library
I've seen a nearly identical utility library called await-to-js but that's what I was going to suggest as well as the pattern does make error handling a lot easier and less nested.
Also considering how Javascript works I don't see an end to this dilemma any time soon. You actually made me look up pattern matching for typescript again, and apparently there is a pretty nice looking tc39 proposal now, compared to the last time I looked it up. Combining this with an either type or something like that could save some headaches, although the issue with exceptions being thrown by every library still remains. The language is still evolving afterall and the course it's been taking lately is looking good. It can only get better.
Agreed, and using `Object.freeze` everywhere is a poor man's substitution for immutability by default. I'm cautiously optimistic about the tuples and records proposal but it could still take a while. In particular, I'm interested in what the TypeScript team can introduce to take advantage of those.