Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Why I get no error when I use Record string with a number value?

$
0
0

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' }]))  };

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>