Code Monkey home page Code Monkey logo

Comments (5)

yazla avatar yazla commented on August 23, 2024

I have just trapped on this, and it confused me a lot. I expected "props" to have the same signature as "prop" except for input args. Why isn't it so? I believe loosing a bit of type safety is a affordable trade off here. At least there could be all possible overloads to choose from.
So as for me "props" should look like this.

props<T>(ps: string[]): (obj: any) => T[];

from npm-ramda.

jcristovao avatar jcristovao commented on August 23, 2024

Hey, I'm sorry for chiming in, but I think there are a lot of issues here:

  1. The issue originally report by @donnut seems to no longer apply as of typescript 1.8, as indicated by the referenced stackoverflow question. Hence, we can (and should?) have the [index:string]

1.a) I really don't understand the third to six lines of the type signature in propEq:

    propEq<T>(name: string, val: T, obj: any): boolean;
    propEq<T>(name: number, val: T, obj: any): boolean;
    propEq<T>(name: string, val: T): (...args: any[]) => boolean;
    propEq<T>(name: number, val: T): (...args: any[]) => boolean;
    propEq<T>(name: string): (val: T, ...args: any[]) => boolean;
    propEq<T>(name: number): (val: T, ...args: any[]) => boolean;

Shouldn't it be:

    propEq<T>(name: string, val: T, obj: any): boolean;
    propEq<T>(name: number, val: T, obj: any): boolean;
    propEq<T>(name: string, val: T): (obj:any]) => boolean;
    propEq<T>(name: number, val: T): (obj:any) => boolean;
    propEq<T>(name: string): (val: T, obj:any) => boolean;
    propEq<T>(name: number): (val: T, obj:any) => boolean;

Or better yet, obj:{[index:string]: any } ?

  1. I totally agree with @yazla that props and prop should have related signatures, which is not the case, and it is confusing. But given the new capabilities of the typescript compiler I mentioned above, I actually think it is prop which needs to be changed.

What do you think?

from npm-ramda.

jcristovao avatar jcristovao commented on August 23, 2024

Hum, I stand corrected, this seems to only be fixed on typescript 1.9, which is now bleeding edge / alpha. So, I guess if we are still some months away of having this PR fixed in a more 'production ready' environment :(

from npm-ramda.

donnut avatar donnut commented on August 23, 2024

That explains why my quick try wasn't able to reproduce it.

from npm-ramda.

KiaraGrouwstra avatar KiaraGrouwstra commented on August 23, 2024

At this point, TS 2.0 is stable, so the original issue should no longer be a concern. propEq has been adjusted in line with @jcristovao's request by now.

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.