/
member.signature.title.tsx
46 lines (45 loc) · 1.7 KB
/
member.signature.title.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { join, renderTypeParametersSignature, wbr } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
import { JSX } from "../../../../utils";
import { ReflectionKind, SignatureReflection } from "../../../../models";
export const memberSignatureTitle = (
context: DefaultThemeRenderContext,
props: SignatureReflection,
{ hideName = false, arrowStyle = false }: { hideName?: boolean; arrowStyle?: boolean } = {}
) => (
<>
{!hideName ? (
wbr(props.name)
) : (
<>
{props.kind === ReflectionKind.ConstructorSignature && (
<>
{!!props.flags.isAbstract && <span class="tsd-signature-symbol">abstract </span>}
<span class="tsd-signature-symbol">new </span>
</>
)}
</>
)}
{renderTypeParametersSignature(props.typeParameters)}
<span class="tsd-signature-symbol">(</span>
{join(", ", props.parameters ?? [], (item) => (
<>
{!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>}
{item.name}
<span class="tsd-signature-symbol">
{!!item.flags.isOptional && "?"}
{!!item.defaultValue && "?"}
{": "}
</span>
{context.type(item.type)}
</>
))}
<span class="tsd-signature-symbol">)</span>
{!!props.type && (
<>
<span class="tsd-signature-symbol">{arrowStyle ? " => " : ": "}</span>
{context.type(props.type)}
</>
)}
</>
);