From 061d000ae8d505d682cd0e288784d76896a303d1 Mon Sep 17 00:00:00 2001
From: Danylo Batishchev <yoloquence@gmail.com>
Date: Tue, 23 Jul 2024 14:04:42 +0200
Subject: [PATCH] feat: handle newtype primitives

---
 src/utility-types.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/utility-types.ts b/src/utility-types.ts
index 74b604b..d8a84a3 100644
--- a/src/utility-types.ts
+++ b/src/utility-types.ts
@@ -13,7 +13,12 @@ import type {
 } from './create-mutation-keys.types';
 import type { AnyMutableOrReadonlyArray } from './types';
 
-type MergeInsertions<T> = T extends object ? { [K in keyof T]: MergeInsertions<T[K]> } : T;
+type Primitive = boolean | string | number | bigint | symbol | undefined | null;
+
+type MergeInsertions<T> =
+  T extends Primitive ? T
+  : T extends object ? { [K in keyof T]: MergeInsertions<T[K]> }
+  : T;
 
 type inferRecordMutationKeys<Target extends object> = {
   [P in Exclude<keyof Target, 'mutationFn'>]: Target[P] extends AnyMutableOrReadonlyArray ? Target[P]