提交 08344781 编写于 作者: B bokuweb 提交者: Ryan Dahl

fix: use unknown instead of any in testing

上级 2c477dd7
...@@ -48,11 +48,9 @@ export function assert(expr: boolean, msg = "") { ...@@ -48,11 +48,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;
} }
...@@ -60,11 +58,13 @@ export function equal(c: any, d: any): boolean { ...@@ -60,11 +58,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;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册