Skip to content

Commit

Permalink
fix: Support for Object Literals and Destructed Parameters in @param [#…
Browse files Browse the repository at this point in the history
…147] (#148)

* fix: issue #147

* Lint fixes.
  • Loading branch information
rash805115 authored Aug 4, 2024
1 parent b972233 commit d613725
Showing 1 changed file with 67 additions and 16 deletions.
83 changes: 67 additions & 16 deletions packages/plugin/src/components/MemberSignatureBody.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signature.body.hbs

import type { JSONOutput } from 'typedoc';
import { Fragment } from 'react'
import type { JSONOutput, Models } from 'typedoc';
import { useMinimalLayout } from '../hooks/useMinimalLayout';
import type { TSDSignatureReflection } from '../types';
import { Comment, hasComment } from './Comment';
Expand Down Expand Up @@ -85,21 +86,71 @@ export function MemberSignatureBody({ hideSources, sig }: MemberSignatureBodyPro

<ul className="tsd-parameters">
{sig.parameters?.map((param) => (
<li key={param.id}>
<h5>
<Flags flags={param.flags} />
{param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
{`${param.name}: `}
<Type type={param.type} />
<DefaultValue
comment={param.comment}
type={param.type}
value={param.defaultValue}
/>
</h5>

<Comment comment={param.comment} />
</li>
<Fragment key={param.id}>
<li>
<h5>
<Flags flags={param.flags} />
{param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
{`${param.name}: `}
<Type type={param.type} />
<DefaultValue
comment={param.comment}
type={param.type}
value={param.defaultValue}
/>
</h5>

<Comment comment={param.comment} />
</li>

{param.type?.type === 'reflection' && (
<ul key={param.type.declaration.id}>
{param.type.declaration?.children?.map((reflectionChild) => (
<li key={reflectionChild.id}>
<h5>
<Flags flags={reflectionChild.flags} />
{reflectionChild.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
{`${reflectionChild.name}: `}
<Type type={reflectionChild.type} />
<DefaultValue
comment={reflectionChild.comment as unknown as JSONOutput.Comment}
type={reflectionChild.type}
value={reflectionChild.defaultValue}
/>
</h5>

<Comment comment={reflectionChild.comment as unknown as JSONOutput.Comment} />
</li>
))}
</ul>
)}

{param.type?.type === 'union' && (
(param.type as unknown as Models.UnionType).types.filter(
(unionType) => unionType.type === 'reflection').map(
(unionReflectionType) => (
<ul key={(unionReflectionType as Models.ReflectionType).declaration.id}>
{(unionReflectionType as Models.ReflectionType).declaration?.children?.map((unionChild) => (
<li key={unionChild.id}>
<h5>
<Flags flags={unionChild.flags} />
{unionChild.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
{`${unionChild.name}: `}
<Type type={unionChild.type} />
<DefaultValue
comment={unionChild.comment as unknown as JSONOutput.Comment}
type={unionChild.type}
value={unionChild.defaultValue}
/>
</h5>

<Comment comment={unionChild.comment as unknown as JSONOutput.Comment} />
</li>
))}
</ul>
))
)}
</Fragment>
))}
</ul>
</>
Expand Down

0 comments on commit d613725

Please sign in to comment.