One has the following two interfaces;
interface ComponentInterface {
pollution: number,
funds: number
}
interface ConfigInterface {
pollution?: number,
funds?: number
}
Additionally, there is a function that generates objects based on these interfaces;
function generateObject(oConfig: ConfigInterface = {}): ComponentInterface {
// Merging config with component defaults
const objectComponent: ComponentInterface = Object.assign({
pollution: 0
}, oConfig);
// ...
}
The function is called without any arguments like this;
generateObject();
Confusingly, no error is thrown by the compiler here. It seems that { pollution: 0 } is being assigned to a variable expecting a ComponentInterface.