I got this typescript code:
interface SquareConfig
{
color?: string;
width?: number;
}
function createSquare(config: SquareConfig): { color: string; area: number }
{
return { color: "blue", area: 1};
}
let mySquare = createSquare({ colour: "red", width: 100 });
There is a deliberate error when calling the method - the object passed is with a property called "colour" instead of "color".
I don't understand why typescript says its an error, since the "color" property of the interface is defined as an optional parameter...