Skip to content

Commit

Permalink
fix(lens): dont allow non-recs as match.with input (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
krulod authored and BANOnotIT committed Oct 19, 2023
1 parent 70f69c6 commit d66681c
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions packages/lens/src/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,21 @@ import {
isAtom,
throwReatomError,
} from '@reatom/core'
import { isDeepEqual, isRec, isShallowEqual, merge } from '@reatom/utils'
import { isRec, isShallowEqual, merge } from '@reatom/utils'

type Primitive = null | undefined | string | number | boolean | symbol | bigint

export type BuiltIns = Primitive | Date | RegExp

export type PartialDeep<T> = T extends BuiltIns
? T | undefined
: T extends Map<infer K, infer V>
? {} & Map<PartialDeep<K>, PartialDeep<V>>
: T extends Set<infer Item>
? {} & Set<PartialDeep<Item>>
: T extends ReadonlyMap<infer K, infer V>
? {} & ReadonlyMap<PartialDeep<K>, PartialDeep<V>>
: T extends ReadonlySet<infer Item>
? PartialDeepSetReadonly<Item>
: T extends (...arguments_: any[]) => unknown
? T | undefined
: T extends object
? T extends ReadonlyArray<any>
? T
? never
: {
[K in keyof T]?: PartialDeep<T[K]>
}
: unknown
type PartialDeepSetReadonly<Item> = {} & ReadonlySet<PartialDeep<Item>>

interface Match<Expression = any, State = never, Default = undefined>
extends Atom<State | Default> {
Expand Down

0 comments on commit d66681c

Please sign in to comment.