From 8221924d9a814eb8d644b2f47e57687134341cc8 Mon Sep 17 00:00:00 2001 From: Masashi Hirano Date: Sat, 5 Jan 2019 01:59:50 +0900 Subject: [PATCH] Fix to use unknown type in testing/mod.ts (#73) --- testing/mod.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/testing/mod.ts b/testing/mod.ts index f33e743fc0..2200020f69 100644 --- a/testing/mod.ts +++ b/testing/mod.ts @@ -35,11 +35,9 @@ export function assert(expr: boolean, msg = "") { } } -// TODO(ry) Use unknown here for parameters types. -// tslint:disable-next-line:no-any -export function equal(c: any, d: any): boolean { +export function equal(c: unknown, d: unknown): boolean { const seen = new Map(); - return (function compare(a, b) { + return (function compare(a: unknown, b: unknown) { if (Object.is(a, b)) { return true; } @@ -47,11 +45,13 @@ export function equal(c: any, d: any): boolean { if (seen.get(a) === b) { return true; } - if (Object.keys(a).length !== Object.keys(b).length) { + if (Object.keys(a || {}).length !== Object.keys(b || {}).length) { return false; } - for (const key in { ...a, ...b }) { - if (!compare(a[key], b[key])) { + const merged = { ...a, ...b }; + for (const key in merged) { + type Key = keyof typeof merged; + if (!compare(a && a[key as Key], b && b[key as Key])) { return false; } }