Skip to content

Commit 294e1c0

Browse files
kakasooclaude
andcommitted
test: add complex Date edge case tests for DeepStrictMerge
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ca4fcc7 commit 294e1c0

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/features/DeepStrictMerge.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,66 @@ export function test_types_deep_strict_merge_source_only_deeply_nested_object()
159159
type Answer = Equal<Question, { x: number; y: { z: { w: string; v: Date } } }>;
160160
ok(typia.random<Answer>());
161161
}
162+
163+
/**
164+
* Tests that Date is preserved when Target has Date and Source has a non-Date object at the same key.
165+
* Target wins because DeepStrictMerge gives Target precedence, and Date is treated as a leaf.
166+
*/
167+
export function test_types_deep_strict_merge_target_date_vs_source_object() {
168+
type Question = DeepStrictMerge<{ d: Date }, { d: { x: number } }>;
169+
type Answer = Equal<Question, { d: Date }>;
170+
ok(typia.random<Answer>());
171+
}
172+
173+
/**
174+
* Tests that Target (non-Date object) wins when Source has Date at the same key.
175+
* DeepStrictMerge gives Target precedence.
176+
*/
177+
export function test_types_deep_strict_merge_target_object_vs_source_date() {
178+
type Question = DeepStrictMerge<{ d: { x: number } }, { d: Date }>;
179+
type Answer = Equal<Question, { d: { x: number } }>;
180+
ok(typia.random<Answer>());
181+
}
182+
183+
/**
184+
* Tests that Date properties are preserved inside array element merging.
185+
*/
186+
export function test_types_deep_strict_merge_date_in_array_elements() {
187+
type Question = DeepStrictMerge<
188+
{ items: { createdAt: Date; a: number }[] },
189+
{ items: { updatedAt: Date; b: string }[] }
190+
>;
191+
type Answer = Equal<Question, { items: { createdAt: Date; a: number; updatedAt: Date; b: string }[] }>;
192+
ok(typia.random<Answer>());
193+
}
194+
195+
/**
196+
* Tests Date preservation in deeply nested objects (3+ levels) mixed with other properties.
197+
*/
198+
export function test_types_deep_strict_merge_date_deeply_nested_mixed() {
199+
type Question = DeepStrictMerge<
200+
{ a: { b: { c: Date; d: number }; e: Date } },
201+
{ a: { b: { c: Date; f: string }; e: { g: boolean } } }
202+
>;
203+
type Answer = Equal<Question, { a: { b: { c: Date; d: number; f: string }; e: Date } }>;
204+
ok(typia.random<Answer>());
205+
}
206+
207+
/**
208+
* Tests that multiple Date properties at different nesting levels are all preserved correctly.
209+
*/
210+
export function test_types_deep_strict_merge_multiple_dates_various_levels() {
211+
type Question = DeepStrictMerge<
212+
{ created: Date; meta: { updated: Date; info: { archived: Date; name: string } } },
213+
{ deleted: Date; meta: { published: Date; info: { archived: Date; desc: string } } }
214+
>;
215+
type Answer = Equal<
216+
Question,
217+
{
218+
created: Date;
219+
meta: { updated: Date; info: { archived: Date; name: string; desc: string }; published: Date };
220+
deleted: Date;
221+
}
222+
>;
223+
ok(typia.random<Answer>());
224+
}

0 commit comments

Comments
 (0)