// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/templates/reflection.hbs import { useMemo } from 'react'; import type { TSDDeclarationReflection, TSDReflection, TSDSignatureReflection } from '../types'; import { createHierarchy } from '../utils/hierarchy'; import { Comment, hasComment } from './Comment'; import { CommentBadges, isCommentWithModifiers } from './CommentBadges'; import { Hierarchy } from './Hierarchy'; import { Icon } from './Icon'; import { Index } from './Index'; import { Members } from './Members'; import { MemberSignatures } from './MemberSignatures'; import { Parameter } from './Parameter'; import { extractDeclarationFromType, Type } from './Type'; import { TypeParameters } from './TypeParameters'; export interface ReflectionProps { reflection: TSDDeclarationReflection | TSDReflection | TSDSignatureReflection; } // eslint-disable-next-line complexity export function Reflection({ reflection }: ReflectionProps) { const hierarchy = useMemo(() => createHierarchy(reflection), [reflection]); return ( <> {isCommentWithModifiers(reflection.comment) && } {hasComment(reflection.comment) && } {'typeParameter' in reflection && reflection.typeParameter && reflection.typeParameter.length > 0 && // Class reflection.kind !== 128 && ( Type parameters )} {(('extendedBy' in reflection && reflection.extendedBy && reflection.extendedBy.length > 0) || ('extendedTypes' in reflection && reflection.extendedTypes && reflection.extendedTypes.length > 0)) && ( Hierarchy )} {'implementedTypes' in reflection && reflection.implementedTypes && reflection.implementedTypes.length > 0 && ( Implements {reflection.implementedTypes.map((type, i) => ( ))} )} {'implementedBy' in reflection && reflection.implementedBy && reflection.implementedBy.length > 0 && ( Implemented by {reflection.implementedBy.map((type, i) => ( ))} )} {'signatures' in reflection && reflection.signatures && reflection.signatures.length > 0 && ( Callable )} {'indexSignature' in reflection && reflection.indexSignature && ( Indexable [ {reflection.indexSignature.parameters?.map((param) => ( {param.name} {': '} ))} ]: )} > ); }