Replies: 1 comment 1 reply
-
@jrencz Hi, thanks for the suggestion! This is a cool idea. I'll spend some time looking into this when I next get a bit of free time to deep dive into this aspect of the library. I think being able to remap property names would be awesome (an essential) addition to the Mapped type feature. I expect this feature would need to be realized by way of new type ( There's not too much I can implement at this stage, so will convert this issue into a discussion thread for now as new features like this are usually best discussed there. Happy to field any questions if you wanted to have a go at a prototype implementation :) Cheers! |
Beta Was this translation helpful? Give feedback.
-
What I refer to in the title as 'the "key remapping via
as
" approach' is https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-asLooking through resolved issues related to Template Literal and Mapped types I found the resolved #913
Inspired by that I tried to rebuild the example from the TS Handbook, (link below) and I think it shows an idea for a nice feature to be added: a way to use both the
TMappedKey
and the original key inTMappedFunction
.I imagine it would mean
Type.Mapped
knows not only about the "new" keys (as it does now, the 1st argument) but somehow it can be given both the keys and the function that maps keys, not only the function that maps values, theTMappedFunction
.Here's playground with description of the concept, until the point, where the suggested new syntax would make things easier.
Beta Was this translation helpful? Give feedback.
All reactions