I use Record<string, MyUser>
and the key of the object is a number. Why I get no error because I set Record<string>
?
interface MyUser { name: string; id: number; email?: string;}const user = (users: MyUser[]): Record<string, MyUser> => { return users.reduce((a, v) => { return { ...a, [v.id]: v } }, {});}; const find = () => { console.log(user([{ id: 2, name: 'Hosa', email: 'saas@asa.com' }, { id: 2, name: 'Hsasa', email: 'ASDSDA@asa.da' }])) };