Giter Site home page Giter Site logo

Comments (4)

jeddeloh avatar jeddeloh commented on June 3, 2024

So that type t is abstract because the types are unimplemented. You can either cast your field merge function like so:

let myMergeFunction: FieldMergeFunction.Js_.t = Obj.magic((existing, incoming) => { ... })

or you could make a PR to flesh out the types :)

from rescript-apollo-client.

dfalling avatar dfalling commented on June 3, 2024

Perfect- that did the trick! Thank you!

I'd love to PR to help, but the type of this is beyond my understanding... I'm not sure how to have a union type of a function and true that resolve to JS.

module FieldMergeFunction = {
  type t<'existing> =
    | Function(('existing, 'existing) => 'existing)
    | True
}

from rescript-apollo-client.

jeddeloh avatar jeddeloh commented on June 3, 2024

Great! If you do indeed want to do the work of a PR, I'm happy to help guide you a little, but no pressure.

If you do go down that path, please read the contributing section that explains some of the weird Js_ modules

There's an old blog post about representing unions like this in ReScript: https://rescript-lang.org/blog/union-types-in-bucklescript

And there are many examples in the code. Here is one:
https://github.com/jeddeloh/rescript-apollo-client/blob/d75edfd0e4e0a4ac201e2b7424331f6b411b4cd7/src/%40apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res

from rescript-apollo-client.

dfalling avatar dfalling commented on June 3, 2024

Perfect, thank you! I'll close out this issue and push a WIP PR when I get stumped. Thanks!

from rescript-apollo-client.

Related Issues (20)

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.