I do have a static class in typescript that has an async build method like the following:
export default class DbServiceInit {
public static myProperty: string;
public static build = async(): Promise<void> => {
try {
DbServiceInit.myProperty = "ssss";
console.log('My Static Class', DbServiceInit)
} catch (error) { console.error(error); }
}
}
When I am calling it like this:
await DbServiceInit.build();
It logs an empty class:
My Static Class class DbServiceInit {
}
Any help will be appreciated as I can't figure out why is this happening as I would expect the following:
My Static Class class DbServiceInit {
myProperty: 'ssss'
}
myPropertyand you can read it: console.log(DbServiceInit.myProperty). You are not able to see what you want because your example should create a new instance to see what you want: jsfiddle.net/52qza8Lu