4

Though whenStable returns a promise, I'm not allowed to use await.

Below are my tsconfig

"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
  "node_modules/@types"
],

I'm using "typescript": "^2.1.5"

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
Prashan Fernando
  • 281
  • 4
  • 11

1 Answers1

4

As stated in the error message: 'await' is only allowed within async function. When you want to use await, you have to mark the outer function with async keyword.

// example

const myAsyncFunction = async () => {
   // ... some code
   await fixture.whenStable();
   // ... some code
}

When you mark any function with async keyword it returns a promise. Take a look at this question for better explanation of async/await.

Community
  • 1
  • 1
Erik Cupal
  • 2,735
  • 1
  • 19
  • 20