ITADN

Merging non-Partial with Partial results in Partial

#528Closedcjlawson02 创建于 2025-02-12
Resolution: Limitation
C
cjlawson02commented
## Bug Report When merging a non-Partial with a Partial, the type checker believes the final result is a Partial ```typescript import { deepmerge } from "deepmerge-ts"; interface Example { a: string; b: { c: string }; } const x: Example = { a: "test", b: { c: "test2" }, }; const y: Partial<Example> = { b: { c: "test3" }, }; export const result = deepmerge(x, y); // try to access result.b.c; // 'result.b' is possibly 'undefined' ``` ### Expected behavior I would expect the type of `result` to be `Example` ### Actual behavior The type of `result` is `Partial<Example>` ### Steps to reproduce https://codesandbox.io/p/devbox/deepmerge-ts-example-forked-g9dks8
关闭于 2025-02-13 4 条评论