diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/004_set_timeout.ts | 4 | ||||
-rw-r--r-- | tests/012_async.ts | 10 | ||||
-rw-r--r-- | tests/013_dynamic_import.ts | 2 | ||||
-rw-r--r-- | tests/014_duplicate_import.ts | 2 | ||||
-rw-r--r-- | tests/016_double_await.ts | 2 | ||||
-rw-r--r-- | tests/018_async_catch.ts | 2 | ||||
-rw-r--r-- | tests/026_workers.ts | 4 | ||||
-rw-r--r-- | tests/028_args.ts | 8 | ||||
-rw-r--r-- | tests/echo_server.ts | 12 | ||||
-rw-r--r-- | tests/error_005_missing_dynamic_import.ts | 2 | ||||
-rw-r--r-- | tests/fetch_deps.ts | 2 | ||||
-rw-r--r-- | tests/subdir/bench_worker.ts | 2 | ||||
-rw-r--r-- | tests/subdir/test_worker.ts | 2 | ||||
-rw-r--r-- | tests/workers_round_robin_bench.ts | 22 | ||||
-rw-r--r-- | tests/workers_startup_bench.ts | 12 |
15 files changed, 50 insertions, 38 deletions
diff --git a/tests/004_set_timeout.ts b/tests/004_set_timeout.ts index 214b25086..58f899ee3 100644 --- a/tests/004_set_timeout.ts +++ b/tests/004_set_timeout.ts @@ -1,10 +1,10 @@ -setTimeout(() => { +setTimeout((): void => { console.log("World"); }, 10); console.log("Hello"); -const id = setTimeout(() => { +const id = setTimeout((): void => { console.log("Not printed"); }, 10000); diff --git a/tests/012_async.ts b/tests/012_async.ts index 12df73b3e..1f1822c04 100644 --- a/tests/012_async.ts +++ b/tests/012_async.ts @@ -1,9 +1,11 @@ // Check that we can use the async keyword. async function main(): Promise<void> { - await new Promise(resolve => { - console.log("2"); - setTimeout(resolve, 100); - }); + await new Promise( + (resolve): void => { + console.log("2"); + setTimeout(resolve, 100); + } + ); console.log("3"); } diff --git a/tests/013_dynamic_import.ts b/tests/013_dynamic_import.ts index 0812623f6..20dc508db 100644 --- a/tests/013_dynamic_import.ts +++ b/tests/013_dynamic_import.ts @@ -1,4 +1,4 @@ -(async () => { +(async (): Promise<void> => { const { returnsHi, returnsFoo2, diff --git a/tests/014_duplicate_import.ts b/tests/014_duplicate_import.ts index 88f934526..97864fea7 100644 --- a/tests/014_duplicate_import.ts +++ b/tests/014_duplicate_import.ts @@ -4,6 +4,6 @@ import "./subdir/auto_print_hello.ts"; import "./subdir/auto_print_hello.ts"; -(async () => { +(async (): Promise<void> => { await import("./subdir/auto_print_hello.ts"); })(); diff --git a/tests/016_double_await.ts b/tests/016_double_await.ts index 12dfeeba4..9b4801567 100644 --- a/tests/016_double_await.ts +++ b/tests/016_double_await.ts @@ -1,6 +1,6 @@ // This is to test if Deno would die at 2nd await // See https://github.com/denoland/deno/issues/919 -(async () => { +(async (): Promise<void> => { const currDirInfo = await Deno.stat("."); const parentDirInfo = await Deno.stat(".."); console.log(currDirInfo.isDirectory()); diff --git a/tests/018_async_catch.ts b/tests/018_async_catch.ts index f59c22ee2..0d034d798 100644 --- a/tests/018_async_catch.ts +++ b/tests/018_async_catch.ts @@ -11,4 +11,4 @@ async function call(): Promise<void> { } console.log("after try-catch"); } -call().catch(() => console.log("outer catch")); +call().catch((): void => console.log("outer catch")); diff --git a/tests/026_workers.ts b/tests/026_workers.ts index a7deee217..e001f03e6 100644 --- a/tests/026_workers.ts +++ b/tests/026_workers.ts @@ -1,11 +1,11 @@ const jsWorker = new Worker("./tests/subdir/test_worker.js"); const tsWorker = new Worker("./tests/subdir/test_worker.ts"); -tsWorker.onmessage = e => { +tsWorker.onmessage = (e): void => { console.log("Received ts: " + e.data); }; -jsWorker.onmessage = e => { +jsWorker.onmessage = (e): void => { console.log("Received js: " + e.data); tsWorker.postMessage("Hello World"); diff --git a/tests/028_args.ts b/tests/028_args.ts index 15df61555..51c5cb14b 100644 --- a/tests/028_args.ts +++ b/tests/028_args.ts @@ -1,3 +1,5 @@ -Deno.args.forEach(arg => { - console.log(arg); -}); +Deno.args.forEach( + (arg): void => { + console.log(arg); + } +); diff --git a/tests/echo_server.ts b/tests/echo_server.ts index 15c3112ce..73995eab5 100644 --- a/tests/echo_server.ts +++ b/tests/echo_server.ts @@ -2,8 +2,10 @@ const { args, listen, copy } = Deno; const addr = args[1] || "127.0.0.1:4544"; const listener = listen("tcp", addr); console.log("listening on", addr); -listener.accept().then(async conn => { - await copy(conn, conn); - conn.close(); - listener.close(); -}); +listener.accept().then( + async (conn): Promise<void> => { + await copy(conn, conn); + conn.close(); + listener.close(); + } +); diff --git a/tests/error_005_missing_dynamic_import.ts b/tests/error_005_missing_dynamic_import.ts index 437473b63..0420a80bf 100644 --- a/tests/error_005_missing_dynamic_import.ts +++ b/tests/error_005_missing_dynamic_import.ts @@ -1,4 +1,4 @@ -(async () => { +(async (): Promise<void> => { // eslint-disable-next-line const badModule = await import("bad-module.ts"); })(); diff --git a/tests/fetch_deps.ts b/tests/fetch_deps.ts index 530a56283..370a8c561 100644 --- a/tests/fetch_deps.ts +++ b/tests/fetch_deps.ts @@ -7,7 +7,7 @@ async function main(): Promise<void> { const json = await response.json(); const deps = Object.keys(json.devDependencies); console.log("Deno JS Deps"); - console.log(deps.map(d => `* ${d}`).join("\n")); + console.log(deps.map((d): string => `* ${d}`).join("\n")); assert(deps.includes("typescript")); } diff --git a/tests/subdir/bench_worker.ts b/tests/subdir/bench_worker.ts index 6dd2f9541..094cefb80 100644 --- a/tests/subdir/bench_worker.ts +++ b/tests/subdir/bench_worker.ts @@ -1,4 +1,4 @@ -onmessage = function(e) { +onmessage = function(e): void { const { cmdId, action, data } = e.data; switch (action) { case 0: // Static response diff --git a/tests/subdir/test_worker.ts b/tests/subdir/test_worker.ts index 53d38ba96..c8109d131 100644 --- a/tests/subdir/test_worker.ts +++ b/tests/subdir/test_worker.ts @@ -1,4 +1,4 @@ -onmessage = function(e) { +onmessage = function(e): void { console.log(e.data); postMessage(e.data); diff --git a/tests/workers_round_robin_bench.ts b/tests/workers_round_robin_bench.ts index 818a1145f..d8bbbb2de 100644 --- a/tests/workers_round_robin_bench.ts +++ b/tests/workers_round_robin_bench.ts @@ -15,9 +15,11 @@ export type Resolvable<T> = Promise<T> & ResolvableMethods<T>; export function createResolvable<T>(): Resolvable<T> { let methods: ResolvableMethods<T>; - const promise = new Promise<T>((resolve, reject) => { - methods = { resolve, reject }; - }); + const promise = new Promise<T>( + (resolve, reject): void => { + methods = { resolve, reject }; + } + ); // TypeScript doesn't know that the Promise callback occurs synchronously // therefore use of not null assertion (`!`) return Object.assign(promise, methods!) as Resolvable<T>; @@ -38,18 +40,20 @@ async function main(): Promise<void> { const workers: Array<[Map<number, Resolvable<string>>, Worker]> = []; for (var i = 1; i <= workerCount; ++i) { const worker = new Worker("tests/subdir/bench_worker.ts"); - const promise = new Promise(resolve => { - worker.onmessage = e => { - if (e.data.cmdId === 0) resolve(); - }; - }); + const promise = new Promise( + (resolve): void => { + worker.onmessage = (e): void => { + if (e.data.cmdId === 0) resolve(); + }; + } + ); worker.postMessage({ cmdId: 0, action: 2 }); await promise; workers.push([new Map(), worker]); } // assign callback function for (const [promiseTable, worker] of workers) { - worker.onmessage = e => { + worker.onmessage = (e): void => { handleAsyncMsgFromWorker(promiseTable, e.data); }; } diff --git a/tests/workers_startup_bench.ts b/tests/workers_startup_bench.ts index 46b2b2801..53232ed56 100644 --- a/tests/workers_startup_bench.ts +++ b/tests/workers_startup_bench.ts @@ -5,11 +5,13 @@ async function bench(): Promise<void> { const workers: Worker[] = []; for (var i = 1; i <= workerCount; ++i) { const worker = new Worker("tests/subdir/bench_worker.ts"); - const promise = new Promise(resolve => { - worker.onmessage = e => { - if (e.data.cmdId === 0) resolve(); - }; - }); + const promise = new Promise( + (resolve): void => { + worker.onmessage = (e): void => { + if (e.data.cmdId === 0) resolve(); + }; + } + ); worker.postMessage({ cmdId: 0, action: 2 }); await promise; workers.push(worker); |