Skip to content

Commit 5bcfc94

Browse files
fix: use the sublist for function param types is they are not provided in the generic
1 parent 132b6f3 commit 5bcfc94

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/markdown-helpers.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,23 @@ export const rawTypeToTypeInformation = (
221221
// Special case, when the generic type is "Function" then the first N - 1 innerTypes are
222222
// parameter types and the Nth innerType is the return type
223223
if (genericTypeString === 'Function') {
224+
const genericProvidedParams = innerTypes.slice(0, innerTypes.length - 2);
225+
224226
return {
225227
collection,
226228
type: 'Function',
227-
parameters: innerTypes.slice(0, innerTypes.length - 2),
229+
parameters:
230+
// If no param types are provided in the <A, B, C> syntax then we should fallback to the normal one
231+
genericProvidedParams.length === 0
232+
? subTypedKeys
233+
? subTypedKeys.map<MethodParameterDocumentation>(typedKey => ({
234+
name: typedKey.key,
235+
description: typedKey.description,
236+
required: typedKey.required,
237+
...typedKey.type,
238+
}))
239+
: []
240+
: genericProvidedParams,
228241
returns: innerTypes[innerTypes.length - 1],
229242
};
230243
}

0 commit comments

Comments
 (0)