a function just to fill all fields how to iterate generic type keys?
const fillObject = <T extends {}>(obj: T): Record<keyof T, string> => Object.keys(obj) .reduce((acc, key) => ({...acc, [key]: 'my value'}), {} as Record<keyof T, string>) const obj = fillObject({ id: '', lastname: '', firstname: '' }) console.log(obj)
Обсуждают сегодня