Giter Site home page Giter Site logo

How to use this module? about ts-toolbelt HOT 7 CLOSED

millsp avatar millsp commented on July 17, 2024
How to use this module?

from ts-toolbelt.

Comments (7)

millsp avatar millsp commented on July 17, 2024 2
const curry = <Fn extends F.Function>(fn: Fn): F.Curry<Fn> => {
   // your curry stuff
}

from ts-toolbelt.

millsp avatar millsp commented on July 17, 2024 2

Unfortunately, the type inference cannot work this way when it is curried. And there's also a few limitations with currying and generics (which should solve in the future microsoft/TypeScript#5453).

from ts-toolbelt.

millsp avatar millsp commented on July 17, 2024

The curry types from this library are already shipped with ramda. Make sure you have TS >= 3.5 and the latest @types/ramda in your package.json :)

from ts-toolbelt.

Jerry-Hong avatar Jerry-Hong commented on July 17, 2024

@pirix-gh Thanks a lot for your reply.

I test ramda map curry function, It is always error with x unknown.

@types/ramda is lastest version

dependencies
"@types/ramda": "^0.26.19"
"typescript": "^3.5.3"
"ramda": "^0.26.1"

CleanShot 2019-08-20 at 00 48 38

I have look into @types/ramda map's type, it look right. Is it typescript limit? Or there is some thing can workaround?

CleanShot 2019-08-20 at 00 52 09

from ts-toolbelt.

millsp avatar millsp commented on July 17, 2024

You must be new to typescript. I guess that you missed out:

R.map((x: number) => x + 1)([1,2,3])

But this is not related to this library ;)

Cheers

from ts-toolbelt.

Jerry-Hong avatar Jerry-Hong commented on July 17, 2024

@pirix-gh Ya, I just want to can I use ts-toolbelt let typescript know the x type in curry function automatically .
Because this work

R.map(x => x + 1, [1,2,3]); // x is number auto

from ts-toolbelt.

Jerry-Hong avatar Jerry-Hong commented on July 17, 2024

@pirix-gh Thank you so much! I get it. 😀

from ts-toolbelt.

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.