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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeDeepRight returns incompatible if objects contain array props #435

Open
oleg-mtr opened this issue Apr 15, 2019 · 1 comment
Open

Comments

@oleg-mtr
Copy link

interface ITest {
  foo: string[];
  bar: string;
}

const a: ITest = {foo: ["1"], bar: "2"};
const b: ITest = {foo: ["3"], bar: "4"};
const c: ITest = R.mergeDeepRight(a, b);

StaticShot_15-04-2019_18-55-33

@oleg-mtr oleg-mtr reopened this Apr 15, 2019
@oleg-mtr
Copy link
Author

oleg-mtr commented Apr 15, 2019

Workaround R.mergeDeepWith((a, b) => b, a, b)

import * as R from "ramda";

interface ITest {
  foo: string[];
  bar: string;
}

const a: ITest = {foo: ["1"], bar: "2"};
const b: ITest = {foo: ["3"], bar: "4"};
const c: ITest = R.mergeDeepRight(a, b) as ITest; // `as` to prevent TS error
const d: ITest = R.mergeDeepWith((a, b) => b, a,  b);

console.log(c);
console.log(d);
{ foo: [ '3' ], bar: '4' }
{ foo: [ '3' ], bar: '4' }

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