1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-03 17:08:35 -05:00

Fix to use unknown type in testing/mod.ts (#73)

This commit is contained in:
Masashi Hirano 2019-01-05 01:59:50 +09:00 committed by Ryan Dahl
parent 2ece847a82
commit 8221924d9a

View file

@ -35,11 +35,9 @@ export function assert(expr: boolean, msg = "") {
} }
} }
// TODO(ry) Use unknown here for parameters types. export function equal(c: unknown, d: unknown): boolean {
// tslint:disable-next-line:no-any
export function equal(c: any, d: any): boolean {
const seen = new Map(); const seen = new Map();
return (function compare(a, b) { return (function compare(a: unknown, b: unknown) {
if (Object.is(a, b)) { if (Object.is(a, b)) {
return true; return true;
} }
@ -47,11 +45,13 @@ export function equal(c: any, d: any): boolean {
if (seen.get(a) === b) { if (seen.get(a) === b) {
return true; return true;
} }
if (Object.keys(a).length !== Object.keys(b).length) { if (Object.keys(a || {}).length !== Object.keys(b || {}).length) {
return false; return false;
} }
for (const key in { ...a, ...b }) { const merged = { ...a, ...b };
if (!compare(a[key], b[key])) { for (const key in merged) {
type Key = keyof typeof merged;
if (!compare(a && a[key as Key], b && b[key as Key])) {
return false; return false;
} }
} }