types: MethodMap and ExecuteMethodMap should understand optional/required parameters
Author: boneskullCreated Apr 5, 2023Updated Sep 29, 2026
Labelsenhancementhelp neededDXv4
This should be possible. We can cross-reference the values of the required and optional parameters lists with the parameters on the method implementation to ensure the required params are actually required and the optional ones are not.
e.g.:
const executeMethodMap = {
'/session/:sessionId/foo': {
POST: {
command: 'doFoo',
payloadParams: {
required: ['a', 'b'],
optional: ['c']
}
}
}
} as const satisfies ExecuteMethodMap<MyDriver>;
// elsewhere...
class MyDriver extends BaseDriver<SomeConstraints> {
static executeMethodMap = executeMethodMap;
// required params come first, in order
// then optional params
async doFoo(a: string, b: string, c?: string) { // not an error
// stuff
}
}
// an error would occur if doFoo was:
class {
async doFoo(a: string, b: string, c: string) { // c should be optional per executeMethodMap
// stuff
}
}Source: appium/appium