summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasashi Hirano <shisama07@gmail.com>2019-01-05 01:59:50 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-01-04 11:59:50 -0500
commit7c62da8975be64d499a3df47af75eebdee996a35 (patch)
tree047bb9242423f52f32c711c86ddfb3b75841ce03
parent7879a8515f213b3501826777557a9b67442e1fcb (diff)
Fix to use unknown type in testing/mod.ts (denoland/deno_std#73)
Original: https://github.com/denoland/deno_std/commit/8221924d9a814eb8d644b2f47e57687134341cc8
-rw-r--r--testing/mod.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/testing/mod.ts b/testing/mod.ts
index f33e743fc..2200020f6 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;
}
}