Is there a way in TypeScript to pass only one argument into args and have other values be default without using "args = {}" or declaring defaults within the function to avoid issues with intellisense?
function generateBrickPattern (
wallWidth: number,
wallHeight: number,
args = {
maxBrickWidth: 100,
maxBrickHeight: 50,
minBrickWidth: 50,
minBrickHeight: 25
}) {}
generateBrickPattern(500,500,{maxBrickWidth: 75}) //Preferred
generateBrickPattern(500,500,{maxBrickWidth: 75,
maxBrickHeight: 50,
minBrickWidth: 50,
minBrickHeight: 25}) //Not desired
The preferred syntax generates the following error.
Argument of type '{ maxBrickWidth: number; }' is not assignable to parameter of type '{ maxBrickWidth: number; maxBrickHeight: number; minBrickWidth: number; minBrickHeight: number; }...'.