UNPKG

5.2 kBTypeScriptView Raw
1import type ts from "typescript";
2import { type ReferenceType, type SomeType } from "../types.js";
3import { type TraverseCallback } from "./abstract.js";
4import { ContainerReflection } from "./container.js";
5import type { SignatureReflection } from "./signature.js";
6import type { TypeParameterReflection } from "./type-parameter.js";
7import type { Serializer, JSONOutput, Deserializer } from "../../serialization/index.js";
8import { type CommentDisplayPart } from "../comments/index.js";
9import { SourceReference } from "../sources/file.js";
10/**
11 * Stores hierarchical type data.
12 *
13 * @see {@link DeclarationReflection.typeHierarchy}
14 */
15export interface DeclarationHierarchy {
16 /**
17 * The types represented by this node in the hierarchy.
18 */
19 types: SomeType[];
20 /**
21 * The next hierarchy level.
22 */
23 next?: DeclarationHierarchy;
24 /**
25 * Is this the entry containing the target type?
26 */
27 isTarget?: boolean;
28}
29/**
30 * A reflection that represents a single declaration emitted by the TypeScript compiler.
31 *
32 * All parts of a project are represented by DeclarationReflection instances. The actual
33 * kind of a reflection is stored in its ´kind´ member.
34 * @category Reflections
35 */
36export declare class DeclarationReflection extends ContainerReflection {
37 readonly variant: "declaration" | "reference";
38 /**
39 * A list of all source files that contributed to this reflection.
40 */
41 sources?: SourceReference[];
42 /**
43 * Precomputed boost for search results, may be less than 1 to de-emphasize this member in search results.
44 * Does NOT include group/category values as they are computed when building the JS index.
45 *
46 * This is preserved for plugins, and may be removed in 0.28 if no plugins have used it yet.
47 */
48 relevanceBoost?: number;
49 /**
50 * The escaped name of this declaration assigned by the TS compiler if there is an associated symbol.
51 * This is used to retrieve properties for analyzing inherited members.
52 *
53 * Not serialized, only useful during conversion.
54 * @internal
55 */
56 escapedName?: ts.__String;
57 /**
58 * The type of the reflection.
59 *
60 * If the reflection represents a variable or a property, this is the value type.<br />
61 * If the reflection represents a signature, this is the return type.
62 */
63 type?: SomeType;
64 typeParameters?: TypeParameterReflection[];
65 /**
66 * A list of call signatures attached to this declaration.
67 *
68 * TypeDoc creates one declaration per function that may contain one or more
69 * signature reflections.
70 */
71 signatures?: SignatureReflection[];
72 /**
73 * The index signature of this declaration.
74 */
75 indexSignatures?: SignatureReflection[];
76 /**
77 * The get signature of this declaration.
78 */
79 getSignature?: SignatureReflection;
80 /**
81 * The set signature of this declaration.
82 */
83 setSignature?: SignatureReflection;
84 /**
85 * The default value of this reflection.
86 *
87 * Applies to function parameters, variables, and properties.
88 */
89 defaultValue?: string;
90 /**
91 * A type that points to the reflection that has been overwritten by this reflection.
92 *
93 * Applies to interface and class members.
94 */
95 overwrites?: ReferenceType;
96 /**
97 * A type that points to the reflection this reflection has been inherited from.
98 *
99 * Applies to interface and class members.
100 */
101 inheritedFrom?: ReferenceType;
102 /**
103 * A type that points to the reflection this reflection is the implementation of.
104 *
105 * Applies to class members.
106 */
107 implementationOf?: ReferenceType;
108 /**
109 * A list of all types this reflection extends (e.g. the parent classes).
110 */
111 extendedTypes?: SomeType[];
112 /**
113 * A list of all types that extend this reflection (e.g. the subclasses).
114 */
115 extendedBy?: ReferenceType[];
116 /**
117 * A list of all types this reflection implements.
118 */
119 implementedTypes?: SomeType[];
120 /**
121 * A list of all types that implement this reflection.
122 */
123 implementedBy?: ReferenceType[];
124 /**
125 * Contains a simplified representation of the type hierarchy suitable for being
126 * rendered in templates.
127 */
128 typeHierarchy?: DeclarationHierarchy;
129 /**
130 * The contents of the readme file of the module when found.
131 */
132 readme?: CommentDisplayPart[];
133 /**
134 * The version of the module when found.
135 */
136 packageVersion?: string;
137 isDeclaration(): this is DeclarationReflection;
138 hasGetterOrSetter(): boolean;
139 getAllSignatures(): SignatureReflection[];
140 getNonIndexSignatures(): SignatureReflection[];
141 getProperties(): DeclarationReflection[];
142 getChildOrTypePropertyByName(path: string[]): DeclarationReflection | undefined;
143 traverse(callback: TraverseCallback): void;
144 /**
145 * Return a string representation of this reflection.
146 */
147 toString(): string;
148 toObject(serializer: Serializer): JSONOutput.DeclarationReflection;
149 fromObject(de: Deserializer, obj: JSONOutput.DeclarationReflection | JSONOutput.ProjectReflection): void;
150}