diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2019-03-10 04:30:38 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-09 12:30:38 -0500 |
commit | 034e2cc02829c9244b32232074c7a48af827a2fb (patch) | |
tree | bade01606a1ee076c1f753ce99c97ddb1e4edf30 /js/timers_test.ts | |
parent | 8c7a12d1b258f0ef5ab27f49c424331d43e8d97f (diff) |
Migrate from tslint to eslint for linting (#1905)
Diffstat (limited to 'js/timers_test.ts')
-rw-r--r-- | js/timers_test.ts | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/js/timers_test.ts b/js/timers_test.ts index d40c01376..d1bce82a9 100644 --- a/js/timers_test.ts +++ b/js/timers_test.ts @@ -1,7 +1,12 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { test, assertEquals } from "./test_util.ts"; -function deferred() { +function deferred(): { + promise: Promise<{}>; + resolve: (value?: {} | PromiseLike<{}>) => void; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + reject: (reason?: any) => void; +} { let resolve; let reject; const promise = new Promise((res, rej) => { @@ -15,7 +20,7 @@ function deferred() { }; } -function waitForMs(ms) { +async function waitForMs(ms): Promise<number> { return new Promise(resolve => setTimeout(resolve, ms)); } @@ -62,6 +67,10 @@ test(async function timeoutCancelSuccess() { }); test(async function timeoutCancelMultiple() { + function uncalled(): never { + throw new Error("This function should not be called."); + } + // Set timers and cancel them in the same order. const t1 = setTimeout(uncalled, 10); const t2 = setTimeout(uncalled, 10); @@ -80,10 +89,6 @@ test(async function timeoutCancelMultiple() { // Sleep until we're certain that the cancelled timers aren't gonna fire. await waitForMs(50); - - function uncalled() { - throw new Error("This function should not be called."); - } }); test(async function timeoutCancelInvalidSilentFail() { @@ -138,15 +143,15 @@ test(async function intervalCancelSuccess() { test(async function intervalOrdering() { const timers = []; let timeouts = 0; - for (let i = 0; i < 10; i++) { - timers[i] = setTimeout(onTimeout, 20); - } - function onTimeout() { + function onTimeout(): void { ++timeouts; for (let i = 1; i < timers.length; i++) { clearTimeout(timers[i]); } } + for (let i = 0; i < 10; i++) { + timers[i] = setTimeout(onTimeout, 20); + } await waitForMs(100); assertEquals(timeouts, 1); }); |