I want to use an interface to set the data types and then call them in the function while setting a default value if they are not passed through.
I get an error of ',' expected. after canvas in the function. Can't I call it in this way?
// Options
interface options {
canvas?: {
width: number;
height: number;
bgColor: string;
};
brushes?: {
sizeSm: number;
sizeLg: number;
};
}
function initialize(options {canvas.width = 700, brushes.sizeSm = 20}) {
// Do stuff
}
// Call function
initialize({
canvas: {
width: 820,
height: 450,
bgColor: '#fff'
},
brushes: {
sizeSm: 10,
sizeLg: 20
},
});