diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/js/compiler.ts | 3 | ||||
-rw-r--r-- | cli/tests/045_proxy_client.ts | 8 | ||||
-rw-r--r-- | cli/tests/045_proxy_test.ts | 12 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 10 | ||||
-rw-r--r-- | cli/tests/top_level_for_await.js | 10 | ||||
-rw-r--r-- | cli/tests/top_level_for_await.out | 3 | ||||
-rw-r--r-- | cli/tests/top_level_for_await.ts | 10 |
7 files changed, 42 insertions, 14 deletions
diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts index 57e5e3a47..e4953cee2 100644 --- a/cli/js/compiler.ts +++ b/cli/js/compiler.ts @@ -616,6 +616,9 @@ window.compilerMain = function compilerMain(): void { diagnostics = ts.getPreEmitDiagnostics(program).filter( ({ code }): boolean => { + // TS1103: 'for-await-of' statement is only allowed within an async + // function or async generator. + if (code === 1103) return false; // TS1308: 'await' expression is only allowed within an async // function. if (code === 1308) return false; diff --git a/cli/tests/045_proxy_client.ts b/cli/tests/045_proxy_client.ts index 3d7003750..221ac57f6 100644 --- a/cli/tests/045_proxy_client.ts +++ b/cli/tests/045_proxy_client.ts @@ -1,7 +1,3 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -async function main(): Promise<void> { - const res = await fetch("http://localhost:4545/std/examples/colors.ts"); - console.log(`Response http: ${await res.text()}`); -} - -main(); +const res = await fetch("http://localhost:4545/std/examples/colors.ts"); +console.log(`Response http: ${await res.text()}`); diff --git a/cli/tests/045_proxy_test.ts b/cli/tests/045_proxy_test.ts index 0e7225b3f..98225dbf1 100644 --- a/cli/tests/045_proxy_test.ts +++ b/cli/tests/045_proxy_test.ts @@ -55,11 +55,7 @@ async function testModuleDownload(): Promise<void> { http.close(); } -async function main(): Promise<void> { - proxyServer(); - await testFetch(); - await testModuleDownload(); - Deno.exit(0); -} - -main(); +proxyServer(); +await testFetch(); +await testModuleDownload(); +Deno.exit(0); diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index ee8f1384c..09f148736 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -597,3 +597,13 @@ itest!(top_level_await_ts { args: "--allow-read top_level_await.ts", output: "top_level_await.out", }); + +itest!(top_level_for_await { + args: "top_level_for_await.js", + output: "top_level_for_await.out", +}); + +itest!(top_level_for_await_ts { + args: "top_level_for_await.ts", + output: "top_level_for_await.out", +}); diff --git a/cli/tests/top_level_for_await.js b/cli/tests/top_level_for_await.js new file mode 100644 index 000000000..fa3b496a8 --- /dev/null +++ b/cli/tests/top_level_for_await.js @@ -0,0 +1,10 @@ +async function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +}; diff --git a/cli/tests/top_level_for_await.out b/cli/tests/top_level_for_await.out new file mode 100644 index 000000000..4539bbf2d --- /dev/null +++ b/cli/tests/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/cli/tests/top_level_for_await.ts b/cli/tests/top_level_for_await.ts new file mode 100644 index 000000000..9179322d7 --- /dev/null +++ b/cli/tests/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator<number> { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} |