To expand upon what Patrick Roberts said, you cannot do what you are asking, but you can do something like this instead:
class MyClass {
constructor() {
//static initialization
}
async initialize() {
await WhatEverYouWant();
}
static async create() {
const o = new MyClass();
await o.initialize();
return o;
}
}
Then in your code create your object like this:
const obj = await MyClass.create();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…