-
-
Notifications
You must be signed in to change notification settings - Fork 616
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug description
When merging deeply nested optional objects, sub-entries are lost
type OptionalNestedTest = {
Left: {
nested?: {
in_left: string;
sub_nested?: {
number?: number;
};
};
};
Right: {
nested: {
in_right: string;
sub_nested: {
number: number;
};
};
};
};
/*
Merge Right into Left: sub entries are lost
*/
type OptionalNestedRightIntoLeft = MergeDeep<
OptionalNestedTest['Left'],
OptionalNestedTest['Right']
>;
/**
it produces:
type OptionalNestedRightIntoLeft = {
nested: {
in_right: string;
sub_nested: {
number: number;
};
};
}
instead of:
type OptionalNestedRightIntoLeft = {
nested: {
in_left: string; // currently missing
in_right: string;
sub_nested: {
number: number;
};
};
};
*/
/*
Merge Left into Right: it adds som redundant "| undefined" (This may not be a bug)
*/
type OptionalNestedLeftIntoRight = MergeDeep<
OptionalNestedTest['Right'],
OptionalNestedTest['Left']
>;
/*
produces:
type OptionalNestedLeftIntoRight = {
nested?: {
in_right: string;
in_left: string;
sub_nested?: {
number?: number | undefined;
} | undefined;
} | undefined;
}
instead of:
type OptionalNestedRightIntoLeft = {
nested?: {
in_right: string;
in_left: string;
sub_nested?: {
number?: number;
};
};
};
*/
Repro
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working