You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Item 16: Prefer More Precise Alternatives to Index Signatures
Things to Remember
Understand the drawbacks of index signatures: much like any, they erode type safety and reduce the value of language services.
Prefer more precise types to index signatures when possible: ++interface++s, Map, ++Record++s, mapped types, or index signatures with a constrained key space.
declarefunctionrenderAButton(props: ButtonProps): void;interfaceButtonProps{title: string;onClick: ()=>void;}renderAButton({title: 'Roll the dice',onClick: ()=>alert(1+Math.floor(6*Math.random())),theme: 'Solarized',// ~~~~ Object literal may only specify known properties…});