Currently, TypeScript does not support TLA (including 3.7). This means when we emit a bundle, we depend on the TypeScript compiler to generate the modules as AMD modules, and it does not realise that it needs to turn the define callback into an async function, meaning the await that was previously top level now is in a function that isn't async, throwing a syntax error at runtime.
We will need TLA formally supported in TypeScript, instead of just ignoring the error to resolve this.
TLA has landed in TS 3.8. So when that gets released (early Feb 2020) we will be able to resolve this.
Since we use TS as a git submodule we could actually upgrade already... but maybe it鈥檚 better to wait for release.
I would say we would want to at least wait for the RC. Master can be a bit of a wild ride.
The improvements to bundling is part of the solution for top level await. And #3937 will automatically close this without further work.
Most helpful comment
TLA has landed in TS 3.8. So when that gets released (early Feb 2020) we will be able to resolve this.