got one newbie question here. I need to declare the const in the top level of my Typescript file, so it´s accesible by all functions below. The problem is that the value I need to assign to this constant gets returned by the asynchronous function and this is where I got stuck. Asynchronous function cannot be called from the top-level - I can do something like this, but in this case, the constant is no more on the top level and cannot be accessed by other functions.
(async () => {
const myConst = await asyncFunction(params);
})();
The other option is to use let instead of const, like this, but I rather had const up there
let myConst;
(async () => {
myConst = await asyncFunction(params);
})();
Could you advise me? Is there some way out of it so I can declare the const for the global scope and assign it a value based on the async function?
Thanks a lot :)