Code Monkey home page Code Monkey logo

Comments (8)

KiaraGrouwstra avatar KiaraGrouwstra commented on August 23, 2024

Update: so it looks like it should be possible; thanks to the helpful community at the TypeScript repo for helping point that out.
I'm currently still trying to figure out the details though. Anders was already helpful enough to provide a relevant example in his PR:

function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;

My current confusion is w.r.t. how I might be able to reapply constructs like the type T5 = { [P in keyof Item]: Item[P] }; so as to be able to have the result types per key be calculated based on the original type in the object for that value along with the function in/out types. Open to ideas.

from npm-ramda.

KiaraGrouwstra avatar KiaraGrouwstra commented on August 23, 2024

Made a PR for this here now.

from npm-ramda.

jonaskello avatar jonaskello commented on August 23, 2024

I think in keyof syntax is new in TS 2.1 so it would be required to run?
For me that is totally OK as I want to add ReadOnlyArray in #113 that is only supported in TS 2.0 :-).

from npm-ramda.

KiaraGrouwstra avatar KiaraGrouwstra commented on August 23, 2024

Yeah, I'm under the impression it's pretty new. That said, I imagine there shouldn't be too many downsides to upgrading...

from npm-ramda.

blakeembrey avatar blakeembrey commented on August 23, 2024

This can be supported once 2.2.0 is released as stable. 2.1 is currently in RC, and keyof is currently in the nightlies.

from npm-ramda.

KiaraGrouwstra avatar KiaraGrouwstra commented on August 23, 2024

@blakeembrey: Yeah, basic support (preserving keys) is possible with keyof, though as it stands the full intention here (types separate by key, rather than assuming they're all homogeneous) so far isn't it seems -- note TypeScript's mhegazy couldn't quite figure this out yet either, and eventually recommended following this existing thread.
That said, it definitely seems time to jack up this TS version. :)

from npm-ramda.

blakeembrey avatar blakeembrey commented on August 23, 2024

Sounds great. I just found the thread because I was using pick and the latest nightly, and this issue covered the new keyof feature. I'm sure there's some other places where it'll be useful too. Looking forward to 2.2 stable myself, updating the RethinkDB definition will be lots of fun too 😄

from npm-ramda.

KiaraGrouwstra avatar KiaraGrouwstra commented on August 23, 2024

This is mostly blocked by microsoft/TypeScript#6606, will retry after.

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.