Well, I want to write a bit tricky generic function type for transforming data. For single object it's easy:
export type SingleObjFunction<InputDataType, OutputDataType> =
(object: InputDataType) => OutputDataType;
However, for array of objects I want the function which return either an object with field: OutputDataType[] property inside, or plain array;
Is it possible to get this key of property from another generic parameter, like this:
export type MultipleObjFunction<
InputDataType,
OutputDataType,
InnerField extends (string | undefined),
FunctionResult = InnerField extends string
? { [Key: valueof InnerField]: OutputDataType[] }
: OutputDataType[]
> = (objs: InputDataType[]) => FunctionResult
I know there is no such thing as valueof, but may be there is another way to do so?