typed-typings / npm-ramda

TypeScript's type definitions for Ramda
MIT License
384 stars 64 forks source link

mergeDeepRight returns incompatible if objects contain array props #435

Open oleg-mtr opened 5 years ago

oleg-mtr commented 5 years ago
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 commented 5 years ago

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' }