1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 04:48:52 -05:00

fix(cli): don't ignore diagnostics about for await (#12116)

Fixes #12115
This commit is contained in:
Kitson Kelly 2021-09-17 16:54:52 +10:00 committed by GitHub
parent 00948a6d68
commit 99de9eb4c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 3 deletions

View file

@ -622,6 +622,12 @@ itest!(error_026_remote_import_error {
http_server: true,
});
itest!(error_for_await {
args: "run --reload error_for_await.ts",
output: "error_for_await.ts.out",
exit_code: 1,
});
itest!(error_missing_module_named_import {
args: "run --reload error_missing_module_named_import.ts",
output: "error_missing_module_named_import.ts.out",

14
cli/tests/testdata/error_for_await.ts vendored Normal file
View file

@ -0,0 +1,14 @@
const listener = Deno.listen({ port: 8080 });
for await (const conn of listener) {
handleConn(conn);
}
function handleConn(conn: Deno.Conn) {
const httpConn = Deno.serveHttp(conn);
for await (const event of httpConn) {
event.respondWith(new Response("html", { status: 200 }));
}
}
export {};

View file

@ -0,0 +1,10 @@
[WILDCARD]
error: TS1103 [ERROR]: 'for await' loops are only allowed within async functions and at the top levels of modules.
for await (const event of httpConn) {
~~~~~
at [WILDCARD]error_for_await.ts:9:7
TS1356 [ERROR]: Did you mean to mark this function as 'async'?
function handleConn(conn: Deno.Conn) {
~~~~~~~~~~
at [WILDCARD]error_for_await.ts:7:10

View file

@ -148,9 +148,6 @@ delete Object.prototype.__proto__;
// when that file is a module, but this file has no imports or exports.
// Consider adding an empty 'export {}' to make this file a module.
1375,
// TS1103: 'for-await-of' statement is only allowed within an async function
// or async generator.
1103,
// TS2306: File 'file:///Users/rld/src/deno/cli/tests/testdata/subdir/amd_like.js' is
// not a module.
2306,