A little confusion of TypeScript bypassing compiler check

when you encounter a problem in the process of learning TypeScript, take a look at the following code

In the section
  TypeScript  additional type checking, solutions are given to avoid compiler errors in the code. 

my confusion is, why can this method circumvent compiler type checking?

Jun.30,2022


,,[propName: string]: any,

interface SquareConfig {
  color?: string;
  width?: number;
  [propName: string]: any;
}

let squareOptions = { colour: "red", width: 100 };
let mySquare = createSquare(squareOptions);
Menu