3 ms·
Not true, most of that can be done with TypeScript. $Values might be the only one missing.
by ng12 8y ago
Not true, most of that can be done with TypeScript. $Values might be the only one missing.
- WorldMaker 8y ago$Values should be possible with Typescript 3.0+ conditional infer types, presumably something very similar to the built-in ReturnType<T> conditional infer type. Untested and off the top my head but maybe something like: type Values<T> = T extends { [K keyof T]: infer R } ? R : any
- wyze 8y agoIt works, just need to add `in` in-between `K` and `keyof`.
- wyze 8y agoLooks like $Values can be written as follows in TypeScript: type Props = { age: number name: number } type Values = Props[keyof Props]