Yes, I would agree. I posted a similar comment down below. If the async functions we're calling do their own error handling, then it may not be necessary, but if they don't, or you're not sure, it's good to have the result data provided by allSettled()
It's not a stupid idiom, it's just passing an array to an async function and receiving an array as a return value. If it's easier for you, you can type
This isn't an anti-pattern, and you don't need write it like this. Just use:
const [states, addressTypes, phoneTypes] = await Promise.all([GetAllStates(), FetchAddressTypes(), FindPhoneTypes()]);
For this particular case,
Promise.allSettled()
would be probably be preferable.Though I guess it depends on how you want to do error handling.
Yes, I would agree. I posted a similar comment down below. If the async functions we're calling do their own error handling, then it may not be necessary, but if they don't, or you're not sure, it's good to have the result data provided by
allSettled()
That looks really ugly to me. You have to read it left, right, left right, left, right.
You'll probably also lose all typing information if you do it like this (although TypeScript already can type a lot of stupid Javascript idioms).
It's not a stupid idiom, it's just passing an array to an async function and receiving an array as a return value. If it's easier for you, you can type
but why would you want to do that???