1

I want to create a variable in typescript define as "getter", but the contect return be async like this;

class MyClass {
    async get isValid: boolean {
         return await myService.get("endPoint").value;
    }
}

But I'm getting the following error:

'async' modifier cannot be used here.

In typescript, it is possible to create asynchronous getters?

Ricardo Rocha
  • 14,612
  • 20
  • 74
  • 130
  • 1
    This can help you. https://stackoverflow.com/questions/33879401/es6-class-es2017-async-await-getter – Vladimir Bogomolov Nov 11 '19 at 14:58
  • `return await myService.get("endPoint").value;` if this is the real code, what's the purpose? It's no different than having a regular getter and returning `return myService.get('endPoint').value`; – Nicholas Tower Nov 11 '19 at 15:01

0 Answers0