Skip to content

Commit

Permalink
Support top-level-await in TypeScript (#3024)
Browse files Browse the repository at this point in the history
  • Loading branch information
ry authored Sep 30, 2019
1 parent 5f7ab48 commit ae26a9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,8 @@ itest!(top_level_await {
args: "--allow-read top_level_await.js",
output: "top_level_await.out",
});

itest!(top_level_await_ts {
args: "--allow-read top_level_await.ts",
output: "top_level_await.out",
});
3 changes: 3 additions & 0 deletions cli/tests/top_level_await.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const buf: Uint8Array = await Deno.readFile("hello.txt");
const n: number = await Deno.stdout.write(buf);
console.log(`\n\nwrite ${n}`);
3 changes: 3 additions & 0 deletions js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ window.compilerMain = function compilerMain(): void {

diagnostics = ts.getPreEmitDiagnostics(program).filter(
({ code }): boolean => {
// TS1308: 'await' expression is only allowed within an async
// function.
if (code === 1308) return false;
// TS2691: An import path cannot end with a '.ts' extension. Consider
// importing 'bad-module' instead.
if (code === 2691) return false;
Expand Down

0 comments on commit ae26a9c

Please sign in to comment.