Is there a way to get async properties with destructuring in JavaScript/TypeScript?
Like this:
class A {
public get x() {
return this.getX()
}
private async getX() {
return 5
}
}
async function f(a : A) {
const { x } = a
console.log(x) // Promise
}
async function g(a : A) {
// works as const x = await a.x
const { await x } = a
console.log(x) // 5
}
const { x } = await aPromisesince it is waiting fora, not fora.x.await a.xand(await a).xconst x = await a.x