Skip to content

Commit

Permalink
fix: Fix anonymous function types in params table
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Jul 15, 2021
1 parent 35d8966 commit 0047faf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Expand Up @@ -2,7 +2,7 @@ import { ParameterReflection, ReflectionKind } from 'typedoc';

import { comment } from './comment';
import { stripLineBreaks } from './strip-line-breaks';
import { type } from './type';
import { getReflectionType, type } from './type';

export function parameterTable(this: ParameterReflection[]) {
const flattenParams = (current: any) => {
Expand Down Expand Up @@ -60,7 +60,11 @@ function table(parameters: any) {
}\``,
);

row.push(type.call(parameter.type, 'object'));
row.push(
parameter.type
? type.call(parameter.type, 'object')
: getReflectionType(parameter, 'object'),
);

if (showDefaults) {
row.push(getDefaultValue(parameter));
Expand Down
Expand Up @@ -17,6 +17,7 @@ import {
UnionType,
UnknownType,
} from 'typedoc/dist/lib/models/types';

import MarkdownTheme from '../../theme';
import { escape } from './escape';

Expand All @@ -39,6 +40,7 @@ export function type(
| IndexedAccessType
| UnknownType
| InferredType,

collapse: Collapse = 'none',
emphasis = true,
) {
Expand Down Expand Up @@ -116,7 +118,10 @@ function getLiteralType(model: LiteralType) {
return `\`\`${JSON.stringify(model.value)}\`\``;
}

function getReflectionType(model: DeclarationReflection, collapse: Collapse) {
export function getReflectionType(
model: DeclarationReflection,
collapse: Collapse,
) {
if (model.signatures) {
return collapse === 'function' || collapse === 'all'
? `\`fn\``
Expand Down
Expand Up @@ -84,7 +84,7 @@ Some nested params.
| \`params.nestedObj\` | \`Object\` | A nested object. |
| \`params.nestedObj.name\` | \`string\` | - |
| \`params.nestedObj.obj\` | \`Object\` | - |
| \`params.nestedObj.obj.name\` | | - |
| \`params.nestedObj.obj.name\` | () => \`void\` | - |
| \`params.nestedObj.value\` | \`number\` | - |
| \`params.parent?\` | \`number\` | - |
| \`context\` | \`any\` | The context of the method call. |
Expand Down

0 comments on commit 0047faf

Please sign in to comment.