I want to create a Object with all props and empty values based on a given type.
For example:
type User = {
name: string
}
export const populateArrayWithOption = (
arrayToPopulate: Array<any>,
): Array<any> => {
// the following is pseudo and what I actually look for
return [someWayToGenerateAObjectBasedOnType(User), ...arrayToPopulate];
/**
* Output of someWayToGenerateAObjectBasedOnType(User) should be:
* { name: "" }
*/
};
PS. I know about the any type, its example code.