Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lens): dont allow non-recs as match.with input #675

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading