News for hackers. Stuff that matters.
Re:TypeScript 3.7 by yawaramin on Tuesday November 05, 2019 @09:19PM (#21459094)
IIFEs are an option:

    const result = await (() => {
      try {
        return funcThatReturnSomeType();
      } catch (err) {
        doSomethingWithErr(err);
      }
    })();
Re:TypeScript 3.7 by saurik on Wednesday November 06, 2019 @02:54AM (#21460543)
I don't think this is correct, as the try catch will only catch errors that happen while returning the promise, not awaiting it; you need to do this:

    const result = await (async () => {
      try {
        return await funcThatReturnSomeType();
      } catch (err) {
        doSomethingWithErr(err);
      }
    })();
Re:TypeScript 3.7 by yawaramin on Thursday November 07, 2019 @07:29PM (#21478977)
You may be right, proving the old adage that the best way to get an answer on the internet is to post a wrong answer ;-)
Re:TypeScript 3.7 by jkoudys on Wednesday November 06, 2019 @06:01AM (#21461388)
Iffys are a nice go-to in ts in general, because type inference is so handy and I'd rather not have a big pile of typed `let`s at the top that I have to assign into later. Even something as simple as a switch plays nicer if you iffy it and use it like an expression (similar to a match is rust)
Re:TypeScript 3.7 by smt88 on Wednesday November 06, 2019 @01:37AM (#21460236)
That is so much harder to read though...