So how do we fix our function to make it type-correct? One possible solution is to provide a default value for the max parameter which only kicks in when undefined is passed. That way, the parameter will still be optional, but will always contain a value of type number: