Skip to content

Commit

Permalink
Merge pull request #143 from ahrjarrett/@ahrjarrett/v0.44.2
Browse files Browse the repository at this point in the history
fix: shifts symbol index edge case to `any.record`
  • Loading branch information
ahrjarrett authored May 26, 2024
2 parents 24a19fd + 9f95df1 commit 906f2dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-pandas-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"any-ts": patch
---

fix: account for contravariance in index signature of `any.dict`
2 changes: 1 addition & 1 deletion src/any/any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ declare namespace any {
export type four<first = _, second = _, third = _, fourth = _> = readonly [_1: first, _2: second, _3: third, _4: fourth]
export type triple<type extends three = three> = type
export type ternary<type extends some.ternary = some.ternary> = type
export type record<type extends globalThis.Record<string, _> = globalThis.Record<string, _>> = type
export type record<type extends globalThis.Record<string, _> = globalThis.Record<keyof never, _>> = type

export type predicate<type extends some.predicate = some.predicate> = type
export type asserts<target = _> = never | some.asserts<any, target>
Expand Down
2 changes: 1 addition & 1 deletion src/lens/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export namespace Tree {
= mut<Tree.go<paths>>;

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 extends any.index>(k: k): any.typeguard<any.type, any.indexedBy<k>>
function has<k extends any.index, v>(k: k, guard: any.guard<v>): any.typeguard<any.type, { [p in k]: v }>
Expand Down

0 comments on commit 906f2dc

Please sign in to comment.