Skip to content

Strangly behaviour that merged types #377

Answered by RebeccaStevens
SettingDust asked this question in Q&A
Discussion options

You must be logged in to vote

Ahh, I think I know what you're referring to now.

So currently DeepMergeHKT needs a tuple in order to work out the output type. This tuple represents the order in which the parameters are passed in.

DeepMergeHKT<[{ a: 1 }, { a: "c"; b: 0 }], DeepMergeMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData> will evaluate to {a: "c"; b: 0;}, but if you swap the order of the elements, you'll get {a: 1; b: 0;}.

When an array is passed, it make sense that { a: 1 | "c"; b: 0; } should be the output type rather than unknown. I'll look into whether or not this would be an easy change to make to the current implementation.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@SettingDust
Comment options

@RebeccaStevens
Comment options

Answer selected by SettingDust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants