I created a function that receives a string
keys based object
with any desired value.
The function definition line:
export const pickFromObj = <
Obj extends { [K: string]: unknown },
PickKeys extends keyof Obj
>(object: Obj, keys: PickKeys[]) => {
First I would like to know if there is any way to make this shorter.
In addition, when I pass some the following object to the function, I receive the following error from TS compiler:
Argument of type 'IExample' is not assignable to parameter of type '{ [x: string]: unknown; }'.
Index signature is missing in type 'IExample'.ts(2345)
IExample:
export interface IExample {
fromAddress: string;
toAddress: string;
status: number;
}