It caught me off guard when I discovered that TypeScript allows the following code:
interface IFoo {
bar: string;
}
const foo: IFoo = {bar: 'bar'};
console.log(
foo['anything'] // I want TypeScript to stop this
);
Is there a way to restrict the use of [] accessor when it's not intended?