Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

O.Merge with nested objects should compute. #323

Open
gautelo opened this issue Oct 14, 2022 · 0 comments
Open

O.Merge with nested objects should compute. #323

gautelo opened this issue Oct 14, 2022 · 0 comments

Comments

@gautelo
Copy link

gautelo commented Oct 14, 2022

馃悶 Bug Report

Describe the bug

When you merge two nested objects the MergeDeepObject type is left in the output type for nested object properties.

Reproduce the bug

declare type Source = {
	nested: {
		a: number,
	}
}

declare type Override = {
	nested: {
		b: number,
	}
}

declare type Merged = O.Merge<Source, Override, 'deep'>;
// expected =>
// type Merged = {
// 	nested: {
// 		 a: number;
// 		 b: number;
// 	};
// }

// actual =>
// type Merged = {
// 	nested: MergeDeepObject<{
// 		 a: number;
// 	}, {
// 		 b: number;
// 	}, BuiltIn, undefined, never>;
// }

Expected behavior

See expected output in ts above.

Possible Solution

Doing an A.Compute<> on the type defind by MergeDeepObject seem to fix it.

Additional context

I'm unsure about the ramifications of doing Computes inside low level library types in this way. There might be a performance reason that says you should only call Compute in app code and not inside the library or something like that.

Frankly I'm trying to write a similar type to the ts-toolbelt 'deep' mode capable types and would like to know what is and is not a good idea. ;) So even if you decline this bug report, I'd appreciate an explanation of why this is bad, if it is indeed a bad suggestion.

PS: ts-toolbelt is very cool, so thanks for making it! :) Been learning a lot by looking at the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant