From 061d000ae8d505d682cd0e288784d76896a303d1 Mon Sep 17 00:00:00 2001 From: Danylo Batishchev 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 extends object ? { [K in keyof T]: MergeInsertions } : T; +type Primitive = boolean | string | number | bigint | symbol | undefined | null; + +type MergeInsertions = + T extends Primitive ? T + : T extends object ? { [K in keyof T]: MergeInsertions } + : T; type inferRecordMutationKeys = { [P in Exclude]: Target[P] extends AnyMutableOrReadonlyArray ? Target[P]