I have the following interfaces;
interface ComponentInterface {
pollution: number,
funds: number
}
interface ConfigInterface {
pollution?: number,
funds?: number
}
And then I have a function that creates objects based on the interfaces;
function create(oConfig: ConfigInterface = {}): ComponentInterface {
// Merge the config with component defaults
const oComponent: ComponentInterface = Object.assign({
pollution: 0
}, oConfig);
// ...
}
And I'm calling the function without any arguments like;
create();
I don't understand why my compiler isn't throwing an error here. AFAIK I'm assigning { pollution: 0 } to a variable that's expecting a ComponentInterface.