Giter VIP home page Giter VIP logo

Comments (4)

Harris-Miller avatar Harris-Miller commented on July 18, 2024

Not done intentionally. ts-toolbelt is used under the hood for types like this, and a Major version bump of that library happened with the migration over to types-ramda.

This behavior still works as expected

type Foobar = { foo: { bar: string } };

const obj1: Foobar = { foo: { bar: 'hello' } };
const obj2: Foobar = { foo: { bar: 'world' } };

const r: Foobar = mergeDeepLeft(obj1, obj2);

While not ideal, you can get around your issue by doing as unknown as T

function merge<T extends { lang: string }>(arr: T[]) {
  return mergeDeepLeft(arr[0], arr[1]) as unknown as T;
}

See this typescript playground for more details: https://tsplay.dev/mA8zQN

Will look into it is worth wrapping our own for this instead of relying on ts-toolbelt

from types.

sandrosc avatar sandrosc commented on July 18, 2024

While not ideal, you can get around your issue by doing as unknown as T

That's what I ended up doing, thanks for the elaborate answer :).

from types.

Harris-Miller avatar Harris-Miller commented on July 18, 2024

@sandrosc while investigating how to fix this, I found quite a bit wrong with O.Assign for both shallow and deep merges. I took a crack at fixing them and found myself writing my own types to replace O.Assign

It does fix your specific issue, check out the MR: #18

from types.

sandrosc avatar sandrosc commented on July 18, 2024

I took a look at the new types, looks great. Didn't know the 1/0 pattern for if/else, learnt something new :).

from types.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.