Coder Social home page Coder Social logo

where typing about npm-ramda HOT 1 CLOSED

typed-typings avatar typed-typings commented on August 30, 2024
where typing

from npm-ramda.

Comments (1)

jon49 avatar jon49 commented on August 30, 2024

That seems to work, good idea. It would give the user a pointer in the right direction. Although, from playing around with it it doesn't offer the type safety.

interface Pred2<T> {
    (x: any, y: T): boolean
}
interface ObjPred2<T> {
    [index: string]: Pred2<T>;
}
where<T>(spec: ObjPred2<T>, testObj: T): boolean;

// Tests

var spec2: R.ObjPred2<{x: number; y: number}> =  {x: function(val, obj) { return  val + obj.y > 10; }};
R.where(spec2, {x: 2, y: 7}); //=> false
R.where(spec2, {x: 3, y: 8}); //=> true
R.where({x: (val, obj) => val + obj.y > 10}, {x: 3, y: 8})

The above seems to make it more type safe and to fail when obj doesn't use correct properties. Still not working for making x into other property names though. But it is much better than before!

from npm-ramda.

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.