Skip to content

Commit 830d0c3

Browse files
Handle the possibility a function is in a multi-type literal
1 parent 9b9ca25 commit 830d0c3

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

cli.js

100644100755
File mode changed.

lib/dynamic-param-interfaces.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ const flushParamInterfaces = (API, addToOutput) => {
109109
}
110110
}
111111

112+
if (Array.isArray(paramProperty.type)) {
113+
paramProperty.type = paramProperty.type.map((paramPropertyType) => {
114+
if (paramPropertyType.typeName === 'Function' && paramPropertyType.parameters) {
115+
return Object.assign({}, paramPropertyType, { typeName: genMethodString(module.exports, param, paramProperty, paramProperty.parameters, paramProperty.returns, true) });
116+
}
117+
return paramPropertyType;
118+
});
119+
}
112120
if (!Array.isArray(paramProperty.type) && paramProperty.type.toLowerCase() === 'function') {
113121
paramAPI.push(`${paramProperty.name}${utils.isOptional(paramProperty) ? '?' : ''}: ${utils.genMethodString(module.exports, param, paramProperty, paramProperty.parameters, paramProperty.returns, true)};`)
114122
} else {

lib/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ const genMethodString = (paramInterfaces, module, moduleMethod, parameters, retu
150150
}
151151
}
152152
153+
if (Array.isArray(param.type)) {
154+
param.type = param.type.map((paramType) => {
155+
if (paramType.typeName === 'Function' && param.parameters) {
156+
return Object.assign({}, paramType, { typeName: genMethodString(paramInterfaces, module, moduleMethod, param.parameters, param.returns) });
157+
}
158+
return paramType;
159+
})
160+
}
153161
if (param.type === 'Function' && param.parameters) {
154162
paramType = genMethodString(paramInterfaces, module, moduleMethod, param.parameters, param.returns)
155163
}

0 commit comments

Comments
 (0)