This difference likely doesn't affect developers invoking call directly, but it would affect developers that have wrapped Model#call for whatever reason. For example:
function call<T = any>(
functionPath: string | Path,
args?: any[],
refPaths?: PathSet,
thisPaths?: PathSet[],
): ModelResponse<JSONEnvelope<T>> {
// Fails because optional parameters will always be passed as `undefined`.
return model.call(functionPath, args, refPaths, thisPaths);
}
Workaround
The workaround is to use a spread to pass the same number of parameters:
It could be argued both ways that these calling signatures are either the same or different, so I'm unsure on exactly what approach should be taken. Perhaps the input validation can simply ignore a tail of undefineds and validate the rest?
The error message "Invalid argument" is very generic and could include more details to help the developer track down the root cause.
Context
I was surprised that
Model#call
's arguments validation (source) changes depending on the number of arguments provided. For example:This difference likely doesn't affect developers invoking
call
directly, but it would affect developers that have wrappedModel#call
for whatever reason. For example:Workaround
The workaround is to use a spread to pass the same number of parameters:
Change Request
undefined
s and validate the rest?