Skip to content

Commit 948b17f

Browse files
Handle the possibility a function is in a multi-type literal
1 parent f304ea6 commit 948b17f

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
@@ -103,6 +103,14 @@ const flushParamInterfaces = (API, addToOutput) => {
103103
}
104104
}
105105

106+
if (Array.isArray(paramProperty.type)) {
107+
paramProperty.type = paramProperty.type.map((paramPropertyType) => {
108+
if (paramPropertyType.typeName === 'Function' && paramPropertyType.parameters) {
109+
return Object.assign({}, paramPropertyType, { typeName: genMethodString(module.exports, param, paramProperty, paramProperty.parameters, paramProperty.returns, true) });
110+
}
111+
return paramPropertyType;
112+
});
113+
}
106114
if (!Array.isArray(paramProperty.type) && paramProperty.type.toLowerCase() === 'function') {
107115
paramAPI.push(`${paramProperty.name}${utils.isOptional(paramProperty) ? '?' : ''}: ${utils.genMethodString(module.exports, param, paramProperty, paramProperty.parameters, paramProperty.returns, true)};`)
108116
} 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)