summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorbokuweb <bokuweb12@gmail.com>2019-01-03 09:20:29 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-01-02 20:22:44 -0500
commit0834478154cf5e78c1445861cf6d2ebb68463e35 (patch)
tree8cc4e0c7eb39433b9d0c5714df6c452e97ad6009 /js
parent2c477dd7cb37d37f4c8bcf7fd159c08c4cfa1ac1 (diff)
fix: use unknown instead of any in testing
Diffstat (limited to 'js')
-rw-r--r--js/testing/testing.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/js/testing/testing.ts b/js/testing/testing.ts
index 4cf7ea27f..8e11f2a01 100644
--- a/js/testing/testing.ts
+++ b/js/testing/testing.ts
@@ -48,11 +48,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;
}
@@ -60,11 +58,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;
}
}