A constructor must return an instance of the class it ‘constructs’. Therefore, it’s not possible to return Promise<...> and await for it.
You can:
-
Make your public setup
async. -
Do not call it from the constructor.
-
Call it whenever you want to ‘finalize’ object construction.
async function run() { let topic; debug("new TopicsModel"); try { topic = new TopicsModel(); await topic.setup(); } catch (err) { debug("err", err); } }