Is it possible in TypeScript 4 to achieve something similar to the code snippet below using labelled tuples?
type stringProperties<T extends {}> = {[k in keyof T]: string}
This concept would allow me to transform a type like
[foo: boolean, bar: number, baz: any]
into [foo: string, bar: string, baz:string]
Currently, I am struggling to find a way to dynamically capture the labels (as they are not directly present in keyof) and unsure about how to append another label:type pair to an existing tuple type.
I am familiar with the method shown below to add to an unlabeled tuple, however, it always sets the label as first
.
export type Prepend<E, T extends any[]> =
((first: E, ...args: T) => any) extends ((...args: infer U) => any)
? U
: never