Normally, await can only appear in a method that has been marked as async. However, when you write toplevel code (code that's not wrapped in a function), you can't mark the function as async (because there is no function) so you can't use await.
Enabling toplevel await fixes that.
const result = await someFetchOrSomething(str); return result.foo;