From 9065c4b006e354d26496be0dd5a666674e340f16 Mon Sep 17 00:00:00 2001 From: Andrew Jarrett Date: Sun, 26 May 2024 10:32:50 -0500 Subject: [PATCH 1/2] chore: commits changeset --- .changeset/proud-pandas-draw.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/proud-pandas-draw.md diff --git a/.changeset/proud-pandas-draw.md b/.changeset/proud-pandas-draw.md new file mode 100644 index 0000000..373e9b1 --- /dev/null +++ b/.changeset/proud-pandas-draw.md @@ -0,0 +1,5 @@ +--- +"any-ts": patch +--- + +fix: account for contravariance in index signature of `any.dict` From 8d0d11fe838fbeffda570bc9a70d1dfb0ead4cb9 Mon Sep 17 00:00:00 2001 From: Andrew Jarrett Date: Sun, 26 May 2024 10:44:54 -0500 Subject: [PATCH 2/2] fix: `any.record` now accounts for edge cases involving object indices --- src/any/any.ts | 2 +- src/lens/tree.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/any/any.ts b/src/any/any.ts index 4d11073..c72a053 100644 --- a/src/any/any.ts +++ b/src/any/any.ts @@ -107,7 +107,7 @@ declare namespace any { export type four = readonly [_1: first, _2: second, _3: third, _4: fourth] export type triple = type export type ternary = type - export type record = globalThis.Record> = type + export type record = globalThis.Record> = type export type predicate = type export type asserts = never | some.asserts diff --git a/src/lens/tree.ts b/src/lens/tree.ts index 95adb46..2c8f058 100644 --- a/src/lens/tree.ts +++ b/src/lens/tree.ts @@ -147,7 +147,7 @@ export namespace Tree { = mut>; const isKeyable = (u: unknown): u is any.index => ["number", "string", "symbol"].includes(typeof u) - const isObject = (u: unknown): u is any.dict => typeof u === "object" && u !== null + const isObject = (u: unknown): u is any.record => typeof u === "object" && u !== null function has(k: k): any.typeguard> function has(k: k, guard: any.guard): any.typeguard