@cplieger/deadset-ts 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +3 -0
- package/README.md +5 -6
- package/bin/deadset-ts.mjs +24 -0
- package/bin/deadset-ts.ts +2 -1
- package/bin/node-host.ts +28 -0
- package/jsr.json +4 -2
- package/package.json +11 -6
- package/src/config.ts +218 -0
- package/src/discover.ts +198 -0
- package/src/host.ts +29 -0
- package/src/index.ts +29 -1
- package/src/inventory.ts +941 -0
- package/src/kinds.ts +12 -0
- package/src/paths.ts +93 -0
- package/src/position.ts +75 -0
- package/src/print.ts +59 -0
- package/src/ref.ts +179 -0
- package/src/resolve.ts +732 -0
- package/src/run.ts +272 -17
- package/src/schema.ts +401 -0
- package/src/scope.ts +153 -0
- package/src/session.ts +221 -0
- package/src/version.ts +22 -0
package/src/inventory.ts
ADDED
|
@@ -0,0 +1,941 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isClassDeclaration,
|
|
3
|
+
isComputedPropertyName,
|
|
4
|
+
isEnumDeclaration,
|
|
5
|
+
isEnumMember,
|
|
6
|
+
isExportAssignment,
|
|
7
|
+
isExportDeclaration,
|
|
8
|
+
isFunctionDeclaration,
|
|
9
|
+
isGetAccessorDeclaration,
|
|
10
|
+
isIdentifier,
|
|
11
|
+
isInterfaceDeclaration,
|
|
12
|
+
isIntersectionTypeNode,
|
|
13
|
+
isMethodDeclaration,
|
|
14
|
+
isMethodSignatureDeclaration,
|
|
15
|
+
isModuleBlock,
|
|
16
|
+
isModuleDeclaration,
|
|
17
|
+
isNamespaceExport,
|
|
18
|
+
isPrivateIdentifier,
|
|
19
|
+
isPropertyDeclaration,
|
|
20
|
+
isPropertySignatureDeclaration,
|
|
21
|
+
isSetAccessorDeclaration,
|
|
22
|
+
isTypeAliasDeclaration,
|
|
23
|
+
isTypeLiteralNode,
|
|
24
|
+
isUnionTypeNode,
|
|
25
|
+
isVariableStatement,
|
|
26
|
+
ModifierFlags,
|
|
27
|
+
type Node,
|
|
28
|
+
type SourceFile,
|
|
29
|
+
} from "@typescript/native/unstable/ast";
|
|
30
|
+
import type { Symbol as TSSymbol } from "@typescript/native/unstable/sync";
|
|
31
|
+
import type { Host } from "./host.ts";
|
|
32
|
+
import { dirnamePath, joinPath, relativePath } from "./paths.ts";
|
|
33
|
+
import { byPosition, positionKey, renderPosition, type Position } from "./position.ts";
|
|
34
|
+
import { computedComponent, nameComponent, renderRef, type Component, type Module } from "./ref.ts";
|
|
35
|
+
import type { Handle, ProjectView } from "./session.ts";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The symbol inventory of one project: every declaration the target's own files
|
|
39
|
+
* hold, at its own position, with the container it belongs to and the reference
|
|
40
|
+
* that survives an edit above it.
|
|
41
|
+
*
|
|
42
|
+
* Two mechanisms produce it and neither is redundant. A container's symbol table is
|
|
43
|
+
* the binder's own answer, so it holds a member of a declaration that merges with
|
|
44
|
+
* another and it holds a member whatever its visibility, a private name included;
|
|
45
|
+
* a container's syntactic member list holds a member whose key is computed, which
|
|
46
|
+
* the binder resolves later and does not put in the table. The set is the union,
|
|
47
|
+
* keyed by the member's own reference component, so a member both sources name
|
|
48
|
+
* appears once.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* What one declaration is, from the vocabulary the Contract's finding schema
|
|
53
|
+
* closes. A Go rendering of the same vocabulary names other members of it; these
|
|
54
|
+
* are the ones a TypeScript declaration takes.
|
|
55
|
+
*/
|
|
56
|
+
export type SymbolKind =
|
|
57
|
+
| "file"
|
|
58
|
+
| "function"
|
|
59
|
+
| "class"
|
|
60
|
+
| "interface"
|
|
61
|
+
| "type"
|
|
62
|
+
| "enum"
|
|
63
|
+
| "namespace"
|
|
64
|
+
| "variable"
|
|
65
|
+
| "export-alias"
|
|
66
|
+
| "method"
|
|
67
|
+
| "class-member"
|
|
68
|
+
| "interface-method"
|
|
69
|
+
| "type-member"
|
|
70
|
+
| "enum-member"
|
|
71
|
+
| "type-parameter";
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* How a member may be named from outside the container that declares it.
|
|
75
|
+
*
|
|
76
|
+
* The last two are two facts rather than one. A `private` modifier is a
|
|
77
|
+
* compile-time constraint only, so the member is still reachable at run time by its
|
|
78
|
+
* name through a string index, a decorator, a container or a serializer; a private
|
|
79
|
+
* name is not reachable by any of them, because the name does not exist outside the
|
|
80
|
+
* class body. An exemption class that finds its evidence in a name therefore
|
|
81
|
+
* applies to the first and never to the second, and the Contract's exemption
|
|
82
|
+
* vocabulary records that per class.
|
|
83
|
+
*/
|
|
84
|
+
export type Visibility = "public" | "protected" | "private" | "private-name";
|
|
85
|
+
|
|
86
|
+
/** One declaration of the target. */
|
|
87
|
+
export interface InventorySymbol {
|
|
88
|
+
/** The identifier of the declaration's own position, which the graph keys on. */
|
|
89
|
+
readonly id: string;
|
|
90
|
+
/** The stable symbol reference, which survives an edit above the declaration. */
|
|
91
|
+
readonly ref: string;
|
|
92
|
+
/**
|
|
93
|
+
* The display name a text line renders: the chain from the container inward, each
|
|
94
|
+
* component in the spelling a reference gives it, and the declared local name of a
|
|
95
|
+
* default export, whose reference carries its export name instead.
|
|
96
|
+
*/
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly kind: SymbolKind;
|
|
99
|
+
readonly position: Position;
|
|
100
|
+
/** The line the declaration ends on, so its size in source lines is readable. */
|
|
101
|
+
readonly endLine: number;
|
|
102
|
+
/** The container's id: the file for a module-level declaration, empty for a file. */
|
|
103
|
+
readonly parent: string;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the export table of the module or namespace that holds the declaration
|
|
106
|
+
* names it. It is a fact about that one table, so it is false for every member of
|
|
107
|
+
* a class, an interface, a type or an enum and for every type parameter, whose
|
|
108
|
+
* reach outside its container is {@link InventorySymbol.visibility} and the state
|
|
109
|
+
* of the container the parent names.
|
|
110
|
+
*/
|
|
111
|
+
readonly exported: boolean;
|
|
112
|
+
readonly visibility: Visibility;
|
|
113
|
+
/** Whether the declaration is a static member of a class. */
|
|
114
|
+
readonly static: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** What one project's inventory cost at the client boundary. */
|
|
118
|
+
export interface InventoryCost {
|
|
119
|
+
/** Batched symbol lookups. One pass over every module and container of the project. */
|
|
120
|
+
readonly batches: number;
|
|
121
|
+
/** Export-table reads: one per module and one per namespace. */
|
|
122
|
+
readonly exportTables: number;
|
|
123
|
+
/**
|
|
124
|
+
* Member-table reads: one per interface and enum, and two per class, because a
|
|
125
|
+
* class keeps its instance members and its static members in two tables. Never
|
|
126
|
+
* one per member.
|
|
127
|
+
*/
|
|
128
|
+
readonly memberTables: number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** One project's declarations, in position order, and what reading them cost. */
|
|
132
|
+
export interface Inventory {
|
|
133
|
+
/** The compiler configuration the project was opened from. */
|
|
134
|
+
readonly configFile: string;
|
|
135
|
+
readonly symbols: readonly InventorySymbol[];
|
|
136
|
+
readonly cost: InventoryCost;
|
|
137
|
+
/**
|
|
138
|
+
* The module specifiers of the bare star re-exports the project's files carry, in
|
|
139
|
+
* the order they were read. A bare star re-export declares nothing here: the names
|
|
140
|
+
* it carries forward are the declarations of the module it names, so it is a
|
|
141
|
+
* reference to that module and not a declaration of this one.
|
|
142
|
+
*/
|
|
143
|
+
readonly starReExports: readonly string[];
|
|
144
|
+
/**
|
|
145
|
+
* The number of member declarations that were left out because the file declaring
|
|
146
|
+
* them is not one of the target's own files. Such a declaration belongs to another
|
|
147
|
+
* program, so the target's inventory does not name it, and the count is reported so
|
|
148
|
+
* that the omission is a number rather than a silence.
|
|
149
|
+
*/
|
|
150
|
+
readonly outsideOwnFiles: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** A declaration under construction, before its reference is rendered. */
|
|
154
|
+
interface Building {
|
|
155
|
+
readonly file: SourceFile;
|
|
156
|
+
readonly node: Node;
|
|
157
|
+
readonly module: Module;
|
|
158
|
+
readonly position: Position;
|
|
159
|
+
endLine: number;
|
|
160
|
+
readonly kind: SymbolKind;
|
|
161
|
+
/** The chain of the container, without this declaration's own component. */
|
|
162
|
+
readonly parentChain: readonly Component[];
|
|
163
|
+
/**
|
|
164
|
+
* This declaration's own component. A default export's is its export name, which
|
|
165
|
+
* is where the component and the declared name part company.
|
|
166
|
+
*/
|
|
167
|
+
readonly component: Component;
|
|
168
|
+
/** The declared name, where it is not what the component spells. */
|
|
169
|
+
readonly localName: string | undefined;
|
|
170
|
+
readonly parent: Building | undefined;
|
|
171
|
+
readonly visibility: Visibility;
|
|
172
|
+
readonly static: boolean;
|
|
173
|
+
exported: boolean;
|
|
174
|
+
/** The type parameter this declaration is, where it is one. */
|
|
175
|
+
readonly typeParameter: string | undefined;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** A container whose members are read from a symbol table, from the tree, or both. */
|
|
179
|
+
interface Container {
|
|
180
|
+
readonly owner: Building;
|
|
181
|
+
/** The container's name node, which is what a batch resolves to its symbol. */
|
|
182
|
+
readonly nameNode: Node | undefined;
|
|
183
|
+
readonly members: readonly Node[];
|
|
184
|
+
readonly memberKind: SymbolKind;
|
|
185
|
+
/** Whether the container is a class, whose static members are a second table. */
|
|
186
|
+
readonly isClass: boolean;
|
|
187
|
+
/** Whether the container keeps its members in the export table, as an enum does. */
|
|
188
|
+
readonly membersAreExports: boolean;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** A module or namespace whose export table says which of its declarations it exports. */
|
|
192
|
+
interface ExportScope {
|
|
193
|
+
readonly owner: Building;
|
|
194
|
+
readonly nameNode: Node;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const MANIFEST = "package.json";
|
|
198
|
+
|
|
199
|
+
/** One manifest that names a package, and the directory below the root that holds it. */
|
|
200
|
+
interface Named {
|
|
201
|
+
readonly name: string;
|
|
202
|
+
readonly at: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Resolves each file's package scope: the name of the nearest manifest at or above
|
|
207
|
+
* its directory up to the target root, and the file's path below that manifest.
|
|
208
|
+
* Where no manifest up to the root carries a name, the package is a single dot and
|
|
209
|
+
* the path is read from the root, which cannot collide, because a package name never
|
|
210
|
+
* starts with a dot.
|
|
211
|
+
*
|
|
212
|
+
* One directory is read at most once, because a package holds many files and a
|
|
213
|
+
* manifest read is a filesystem call.
|
|
214
|
+
*/
|
|
215
|
+
function packages(host: Host, root: string): (path: string) => Module {
|
|
216
|
+
const named = new Map<string, Named | undefined>();
|
|
217
|
+
|
|
218
|
+
const manifestName = (dir: string): string | undefined => {
|
|
219
|
+
let text: string;
|
|
220
|
+
try {
|
|
221
|
+
text = host.readFile(joinPath(root, dir, MANIFEST));
|
|
222
|
+
} catch {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
let value: unknown;
|
|
226
|
+
try {
|
|
227
|
+
value = JSON.parse(text);
|
|
228
|
+
} catch {
|
|
229
|
+
// A manifest this program cannot read names no package, which is the same
|
|
230
|
+
// answer as an absent one: the file is then scoped by the target root.
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
if (typeof value !== "object" || value === null) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
const name = (value as Record<string, unknown>)["name"];
|
|
237
|
+
return typeof name === "string" && name !== "" ? name : undefined;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const nearest = (dir: string): Named | undefined => {
|
|
241
|
+
if (named.has(dir)) {
|
|
242
|
+
return named.get(dir);
|
|
243
|
+
}
|
|
244
|
+
const name = manifestName(dir);
|
|
245
|
+
const found =
|
|
246
|
+
name !== undefined ? { name, at: dir } : dir === "" ? undefined : nearest(parentOf(dir));
|
|
247
|
+
named.set(dir, found);
|
|
248
|
+
return found;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
return (path) => {
|
|
252
|
+
const found = nearest(parentOf(path));
|
|
253
|
+
if (found === undefined) {
|
|
254
|
+
return { package: ".", path };
|
|
255
|
+
}
|
|
256
|
+
return { package: found.name, path: found.at === "" ? path : path.slice(found.at.length + 1) };
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** The directory one path below the root sits in, and the root itself as the empty path. */
|
|
261
|
+
function parentOf(path: string): string {
|
|
262
|
+
const dir = dirnamePath(path);
|
|
263
|
+
return dir === "." ? "" : dir;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** The modifier flags one node carries, and zero for a node that carries none. */
|
|
267
|
+
function modifiersOf(node: Node): number {
|
|
268
|
+
return (node as { readonly modifierFlags?: number }).modifierFlags ?? 0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** The type parameters one node declares, and none for a node that declares none. */
|
|
272
|
+
function typeParametersOf(node: Node): readonly Node[] {
|
|
273
|
+
if (
|
|
274
|
+
isFunctionDeclaration(node) ||
|
|
275
|
+
isMethodDeclaration(node) ||
|
|
276
|
+
isMethodSignatureDeclaration(node)
|
|
277
|
+
) {
|
|
278
|
+
return node.typeParameters ?? [];
|
|
279
|
+
}
|
|
280
|
+
return [];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* The reference component one declaration name node spells, and undefined for a
|
|
285
|
+
* name the grammar does not represent: a binding pattern, and a computed key whose
|
|
286
|
+
* source text carries a closing bracket.
|
|
287
|
+
*/
|
|
288
|
+
function componentOf(name: Node | undefined): Component | undefined {
|
|
289
|
+
if (name === undefined) {
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
292
|
+
if (isComputedPropertyName(name)) {
|
|
293
|
+
const text = name.expression.getText();
|
|
294
|
+
return text.includes("]") ? undefined : { text, computed: true };
|
|
295
|
+
}
|
|
296
|
+
if (isIdentifier(name) || isPrivateIdentifier(name)) {
|
|
297
|
+
return { text: name.getText(), computed: false };
|
|
298
|
+
}
|
|
299
|
+
if (isStringOrNumericName(name)) {
|
|
300
|
+
// A string or numeric key's own text carries its quotes and its numeric
|
|
301
|
+
// spelling; the reference carries the value, which the component then quotes.
|
|
302
|
+
return { text: literalTextOf(name), computed: false };
|
|
303
|
+
}
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function isStringOrNumericName(name: Node): boolean {
|
|
308
|
+
const text = name.getText();
|
|
309
|
+
return (
|
|
310
|
+
text.startsWith('"') || text.startsWith("'") || text.startsWith("`") || /^[0-9]/u.test(text)
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** One member's identity inside its container: its component, and its side of a class. */
|
|
315
|
+
function memberKey(component: Component, isStatic: boolean): string {
|
|
316
|
+
return `${component.computed ? "[" : ""}${component.text}${isStatic ? ":static" : ""}`;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* The members one type alias declares: the members of the object type it writes, and
|
|
321
|
+
* of every object type that is a direct constituent of a union or an intersection it
|
|
322
|
+
* writes. A constituent naming another type declares nothing here, because that
|
|
323
|
+
* declaration carries its own members.
|
|
324
|
+
*
|
|
325
|
+
* A name two constituents both declare is left out of all of them. The alias stands
|
|
326
|
+
* for such a member, because the two declarations are one member of the type and
|
|
327
|
+
* neither of them is the one a reference to it would name.
|
|
328
|
+
*/
|
|
329
|
+
function aliasMembers(type: Node): readonly Node[] {
|
|
330
|
+
const literals = isTypeLiteralNode(type)
|
|
331
|
+
? [type]
|
|
332
|
+
: isUnionTypeNode(type) || isIntersectionTypeNode(type)
|
|
333
|
+
? type.types.filter(isTypeLiteralNode)
|
|
334
|
+
: [];
|
|
335
|
+
if (literals.length < 2) {
|
|
336
|
+
return literals[0]?.members ?? [];
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const declaring = new Map<string, number>();
|
|
340
|
+
for (const literal of literals) {
|
|
341
|
+
for (const key of new Set(literal.members.map(keyOf))) {
|
|
342
|
+
if (key !== undefined) {
|
|
343
|
+
declaring.set(key, (declaring.get(key) ?? 0) + 1);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return literals.flatMap((literal) =>
|
|
348
|
+
literal.members.filter((member) => {
|
|
349
|
+
const key = keyOf(member);
|
|
350
|
+
return key !== undefined && declaring.get(key) === 1;
|
|
351
|
+
}),
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** One type member's identity, and undefined for a member the grammar cannot name. */
|
|
356
|
+
function keyOf(member: Node): string | undefined {
|
|
357
|
+
const component = componentOf(nameNodeOf(member));
|
|
358
|
+
return component === undefined ? undefined : memberKey(component, false);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** The value one string or numeric key denotes, which is what the reference names. */
|
|
362
|
+
function literalTextOf(name: Node): string {
|
|
363
|
+
const text = name.getText();
|
|
364
|
+
if (text.startsWith('"') || text.startsWith("'") || text.startsWith("`")) {
|
|
365
|
+
return text.slice(1, -1);
|
|
366
|
+
}
|
|
367
|
+
return text;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* The component one declaration's reference carries, and its declared name where the
|
|
372
|
+
* two differ.
|
|
373
|
+
*
|
|
374
|
+
* A declaration its module exports as the default is named `default`, because that is
|
|
375
|
+
* its export name and a module has at most one, so the spelling is unambiguous and it
|
|
376
|
+
* holds for an anonymous declaration too. Its declared name is a fact about the source
|
|
377
|
+
* rather than about the export, so it travels beside the component as the display name.
|
|
378
|
+
*/
|
|
379
|
+
function exportedAs(
|
|
380
|
+
node: Node,
|
|
381
|
+
name: Node | undefined,
|
|
382
|
+
): { readonly component: Component | undefined; readonly localName: string | undefined } {
|
|
383
|
+
const declared = componentOf(name);
|
|
384
|
+
if ((modifiersOf(node) & ModifierFlags.Default) === 0) {
|
|
385
|
+
return { component: declared, localName: undefined };
|
|
386
|
+
}
|
|
387
|
+
return { component: { text: "default", computed: false }, localName: declared?.text };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** The visibility one member declaration's modifiers and name give it. */
|
|
391
|
+
function visibilityOf(node: Node, name: Node | undefined): Visibility {
|
|
392
|
+
if (name !== undefined && isPrivateIdentifier(name)) {
|
|
393
|
+
return "private-name";
|
|
394
|
+
}
|
|
395
|
+
const flags = modifiersOf(node);
|
|
396
|
+
if ((flags & ModifierFlags.Private) !== 0) {
|
|
397
|
+
return "private";
|
|
398
|
+
}
|
|
399
|
+
if ((flags & ModifierFlags.Protected) !== 0) {
|
|
400
|
+
return "protected";
|
|
401
|
+
}
|
|
402
|
+
return "public";
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** The name node of one declaration, for the kinds that carry one. */
|
|
406
|
+
function nameNodeOf(node: Node): Node | undefined {
|
|
407
|
+
return (node as { readonly name?: Node }).name;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** One node's identity across the two mechanisms, which resolve it separately. */
|
|
411
|
+
function nodeKey(file: SourceFile, node: Node): string {
|
|
412
|
+
return `${file.fileName}:${String(node.pos)}:${String(node.end)}`;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** The kind a class element takes: a method, or a property or accessor. */
|
|
416
|
+
function classMemberKind(node: Node): SymbolKind {
|
|
417
|
+
return isMethodDeclaration(node) ? "method" : "class-member";
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** The kind a type element takes: a method of an interface, or any other member. */
|
|
421
|
+
function typeMemberKind(node: Node, inInterface: boolean): SymbolKind {
|
|
422
|
+
return inInterface && isMethodSignatureDeclaration(node) ? "interface-method" : "type-member";
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Every declaration one project's own files hold.
|
|
427
|
+
*
|
|
428
|
+
* `targetRoot` is the absolute path every position is rendered against; a file the
|
|
429
|
+
* program holds that is not below it ends the enumeration rather than being passed
|
|
430
|
+
* over. `host` is the filesystem the manifests that name each file's package are
|
|
431
|
+
* read through, and nothing else is read from it.
|
|
432
|
+
*
|
|
433
|
+
* The order is by rendered position, so two enumerations of one project return the
|
|
434
|
+
* same list whatever order the program reported its files in.
|
|
435
|
+
*/
|
|
436
|
+
export function inventory<Brand>(
|
|
437
|
+
project: ProjectView<Brand>,
|
|
438
|
+
host: Host,
|
|
439
|
+
targetRoot: string,
|
|
440
|
+
): Inventory {
|
|
441
|
+
const files = project.ownSourceFiles();
|
|
442
|
+
const ownFiles = new Set(files.map((file) => file.fileName));
|
|
443
|
+
const moduleOf = packages(host, targetRoot);
|
|
444
|
+
|
|
445
|
+
const building: Building[] = [];
|
|
446
|
+
const byNode = new Map<string, Building>();
|
|
447
|
+
const exportScopes: ExportScope[] = [];
|
|
448
|
+
const containers: Container[] = [];
|
|
449
|
+
const starReExports: string[] = [];
|
|
450
|
+
let outsideOwnFiles = 0;
|
|
451
|
+
|
|
452
|
+
const keep = (record: Building): Building => {
|
|
453
|
+
building.push(record);
|
|
454
|
+
byNode.set(nodeKey(record.file, record.node), record);
|
|
455
|
+
return record;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
for (const file of files) {
|
|
459
|
+
const path = relativePath(targetRoot, file.fileName);
|
|
460
|
+
if (path === undefined) {
|
|
461
|
+
// renderPosition states the refusal, with the root it was rendered against.
|
|
462
|
+
renderPosition(file, targetRoot, 0);
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const module = moduleOf(path);
|
|
466
|
+
const fileRecord = keep({
|
|
467
|
+
file,
|
|
468
|
+
node: file,
|
|
469
|
+
module,
|
|
470
|
+
position: renderPosition(file, targetRoot, 0),
|
|
471
|
+
endLine: renderPosition(file, targetRoot, Math.max(file.end - 1, 0)).line,
|
|
472
|
+
kind: "file",
|
|
473
|
+
parentChain: [],
|
|
474
|
+
// A file's reference names its module, so no component of it is ever spelled;
|
|
475
|
+
// the path is what a text line renders for it.
|
|
476
|
+
component: { text: path, computed: false },
|
|
477
|
+
localName: path,
|
|
478
|
+
parent: undefined,
|
|
479
|
+
visibility: "public",
|
|
480
|
+
static: false,
|
|
481
|
+
exported: false,
|
|
482
|
+
typeParameter: undefined,
|
|
483
|
+
});
|
|
484
|
+
exportScopes.push({ owner: fileRecord, nameNode: file });
|
|
485
|
+
walkStatements(file.statements, fileRecord);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** One declaration of a module, a namespace or a container body. */
|
|
489
|
+
function walkStatements(statements: readonly Node[], owner: Building): void {
|
|
490
|
+
for (const statement of statements) {
|
|
491
|
+
walkStatement(statement, owner);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function declare(
|
|
496
|
+
node: Node,
|
|
497
|
+
owner: Building,
|
|
498
|
+
kind: SymbolKind,
|
|
499
|
+
name: Node | undefined,
|
|
500
|
+
named: { readonly component: Component; readonly localName: string | undefined },
|
|
501
|
+
): Building {
|
|
502
|
+
const at = name ?? node;
|
|
503
|
+
const record = keep({
|
|
504
|
+
file: owner.file,
|
|
505
|
+
node,
|
|
506
|
+
module: owner.module,
|
|
507
|
+
position: renderPosition(owner.file, targetRoot, at.getStart()),
|
|
508
|
+
endLine: renderPosition(owner.file, targetRoot, Math.max(node.end - 1, 0)).line,
|
|
509
|
+
kind,
|
|
510
|
+
parentChain: owner.kind === "file" ? [] : chainOf(owner),
|
|
511
|
+
component: named.component,
|
|
512
|
+
localName: named.localName,
|
|
513
|
+
parent: owner,
|
|
514
|
+
visibility: visibilityOf(node, name),
|
|
515
|
+
static: (modifiersOf(node) & ModifierFlags.Static) !== 0,
|
|
516
|
+
exported: false,
|
|
517
|
+
typeParameter: undefined,
|
|
518
|
+
});
|
|
519
|
+
declareTypeParameters(node, record);
|
|
520
|
+
return record;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function declareTypeParameters(node: Node, owner: Building): void {
|
|
524
|
+
for (const parameter of typeParametersOf(node)) {
|
|
525
|
+
const name = nameNodeOf(parameter);
|
|
526
|
+
if (name === undefined) {
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
keep({
|
|
530
|
+
file: owner.file,
|
|
531
|
+
node: parameter,
|
|
532
|
+
module: owner.module,
|
|
533
|
+
position: renderPosition(owner.file, targetRoot, name.getStart()),
|
|
534
|
+
endLine: renderPosition(owner.file, targetRoot, Math.max(parameter.end - 1, 0)).line,
|
|
535
|
+
kind: "type-parameter",
|
|
536
|
+
parentChain: owner.parentChain,
|
|
537
|
+
component: owner.component,
|
|
538
|
+
localName: undefined,
|
|
539
|
+
parent: owner,
|
|
540
|
+
visibility: "public",
|
|
541
|
+
static: owner.static,
|
|
542
|
+
exported: false,
|
|
543
|
+
typeParameter: name.getText(),
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function walkStatement(node: Node, owner: Building): void {
|
|
549
|
+
if (isFunctionDeclaration(node)) {
|
|
550
|
+
const named = exportedAs(node, node.name);
|
|
551
|
+
if (named.component !== undefined) {
|
|
552
|
+
declare(node, owner, "function", node.name, { ...named, component: named.component });
|
|
553
|
+
}
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (isClassDeclaration(node)) {
|
|
557
|
+
const named = exportedAs(node, node.name);
|
|
558
|
+
if (named.component === undefined) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
const record = declare(node, owner, "class", node.name, {
|
|
562
|
+
...named,
|
|
563
|
+
component: named.component,
|
|
564
|
+
});
|
|
565
|
+
containers.push({
|
|
566
|
+
owner: record,
|
|
567
|
+
nameNode: node.name,
|
|
568
|
+
members: node.members,
|
|
569
|
+
memberKind: "class-member",
|
|
570
|
+
isClass: true,
|
|
571
|
+
membersAreExports: false,
|
|
572
|
+
});
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (isInterfaceDeclaration(node)) {
|
|
576
|
+
const named = exportedAs(node, node.name);
|
|
577
|
+
if (named.component === undefined) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const record = declare(node, owner, "interface", node.name, {
|
|
581
|
+
...named,
|
|
582
|
+
component: named.component,
|
|
583
|
+
});
|
|
584
|
+
containers.push({
|
|
585
|
+
owner: record,
|
|
586
|
+
nameNode: node.name,
|
|
587
|
+
members: node.members,
|
|
588
|
+
memberKind: "interface-method",
|
|
589
|
+
isClass: false,
|
|
590
|
+
membersAreExports: false,
|
|
591
|
+
});
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
if (isTypeAliasDeclaration(node)) {
|
|
595
|
+
const named = exportedAs(node, node.name);
|
|
596
|
+
if (named.component === undefined) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const record = declare(node, owner, "type", node.name, {
|
|
600
|
+
...named,
|
|
601
|
+
component: named.component,
|
|
602
|
+
});
|
|
603
|
+
// A type alias keeps no member table of its own: the members belong to the
|
|
604
|
+
// object types its declaration writes, so the declaration is what carries them.
|
|
605
|
+
const members = aliasMembers(node.type);
|
|
606
|
+
if (members.length > 0) {
|
|
607
|
+
containers.push({
|
|
608
|
+
owner: record,
|
|
609
|
+
nameNode: undefined,
|
|
610
|
+
members,
|
|
611
|
+
memberKind: "type-member",
|
|
612
|
+
isClass: false,
|
|
613
|
+
membersAreExports: false,
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (isEnumDeclaration(node)) {
|
|
619
|
+
const named = exportedAs(node, node.name);
|
|
620
|
+
if (named.component === undefined) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const record = declare(node, owner, "enum", node.name, {
|
|
624
|
+
...named,
|
|
625
|
+
component: named.component,
|
|
626
|
+
});
|
|
627
|
+
containers.push({
|
|
628
|
+
owner: record,
|
|
629
|
+
nameNode: node.name,
|
|
630
|
+
members: node.members,
|
|
631
|
+
memberKind: "enum-member",
|
|
632
|
+
isClass: false,
|
|
633
|
+
membersAreExports: true,
|
|
634
|
+
});
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
if (isModuleDeclaration(node)) {
|
|
638
|
+
const component = componentOf(node.name);
|
|
639
|
+
if (component === undefined) {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
const record = declare(node, owner, "namespace", node.name, {
|
|
643
|
+
component,
|
|
644
|
+
localName: undefined,
|
|
645
|
+
});
|
|
646
|
+
exportScopes.push({ owner: record, nameNode: node.name });
|
|
647
|
+
const body = node.body;
|
|
648
|
+
if (body === undefined) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
if (isModuleBlock(body)) {
|
|
652
|
+
walkStatements(body.statements, record);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
walkStatement(body, record);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (isVariableStatement(node)) {
|
|
659
|
+
for (const declaration of node.declarationList.declarations) {
|
|
660
|
+
const component = componentOf(declaration.name);
|
|
661
|
+
if (component === undefined) {
|
|
662
|
+
// A destructuring pattern declares binding elements, which the reference
|
|
663
|
+
// grammar does not represent; the statement stands for them.
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
declare(declaration, owner, "variable", declaration.name, {
|
|
667
|
+
component,
|
|
668
|
+
localName: undefined,
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (isExportDeclaration(node)) {
|
|
674
|
+
walkExportDeclaration(node, owner);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
if (isExportAssignment(node) && !node.isExportEquals) {
|
|
678
|
+
declare(node, owner, "export-alias", undefined, {
|
|
679
|
+
component: { text: "default", computed: false },
|
|
680
|
+
localName: undefined,
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function walkExportDeclaration(
|
|
686
|
+
node: { readonly exportClause?: Node; readonly moduleSpecifier?: Node },
|
|
687
|
+
owner: Building,
|
|
688
|
+
): void {
|
|
689
|
+
const clause = node.exportClause;
|
|
690
|
+
if (clause === undefined) {
|
|
691
|
+
const specifier = node.moduleSpecifier;
|
|
692
|
+
starReExports.push(specifier === undefined ? "" : literalTextOf(specifier));
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (isNamespaceExport(clause)) {
|
|
696
|
+
const component = componentOf(clause.name);
|
|
697
|
+
if (component !== undefined) {
|
|
698
|
+
declare(clause, owner, "export-alias", clause.name, { component, localName: undefined });
|
|
699
|
+
}
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
for (const element of (clause as { readonly elements?: readonly Node[] }).elements ?? []) {
|
|
703
|
+
const name = nameNodeOf(element);
|
|
704
|
+
const component = componentOf(name);
|
|
705
|
+
if (component !== undefined) {
|
|
706
|
+
declare(element, owner, "export-alias", name, { component, localName: undefined });
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// One batch for every module and every container the walk found, because a
|
|
712
|
+
// checker accessor with an array overload costs one round trip for the batch and
|
|
713
|
+
// one per node without it.
|
|
714
|
+
const batched: Node[] = [
|
|
715
|
+
...exportScopes.map((scope) => scope.nameNode),
|
|
716
|
+
...containers.map((container) => container.nameNode).filter((node) => node !== undefined),
|
|
717
|
+
];
|
|
718
|
+
const handles: Handle<Brand>[] = batched.map((node) => project.handle(node));
|
|
719
|
+
const resolved = project.symbolsAt(handles);
|
|
720
|
+
const symbolOf = new Map<Node, TSSymbol>();
|
|
721
|
+
batched.forEach((node, index) => {
|
|
722
|
+
const symbol = resolved[index];
|
|
723
|
+
if (symbol !== undefined) {
|
|
724
|
+
symbolOf.set(node, symbol);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
let exportTables = 0;
|
|
729
|
+
for (const scope of exportScopes) {
|
|
730
|
+
const symbol = symbolOf.get(scope.nameNode);
|
|
731
|
+
if (symbol === undefined) {
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
exportTables += 1;
|
|
735
|
+
for (const [, exported] of symbol.getExports()) {
|
|
736
|
+
for (const declaration of exported.declarations) {
|
|
737
|
+
const held = project.declarationAt(declaration);
|
|
738
|
+
if (held === undefined) {
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
const record = byNode.get(nodeKey(held.node.getSourceFile(), held.node));
|
|
742
|
+
if (record === undefined) {
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
record.exported = true;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
let memberTables = 0;
|
|
751
|
+
for (const container of containers) {
|
|
752
|
+
const symbol = container.nameNode === undefined ? undefined : symbolOf.get(container.nameNode);
|
|
753
|
+
const seen = new Map<string, Building>();
|
|
754
|
+
if (symbol !== undefined) {
|
|
755
|
+
if (!container.membersAreExports) {
|
|
756
|
+
memberTables += 1;
|
|
757
|
+
outsideOwnFiles += readTable(container, symbol.getMembers(), seen, false);
|
|
758
|
+
}
|
|
759
|
+
if (container.membersAreExports || container.isClass) {
|
|
760
|
+
memberTables += 1;
|
|
761
|
+
outsideOwnFiles += readTable(container, symbol.getExports(), seen, container.isClass);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
completeFromTree(container, seen);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* One container's members as its symbol table holds them, each positioned at the
|
|
769
|
+
* declaration the table names. A member with no declaration is the language's own
|
|
770
|
+
* (a class's `prototype`), and a member declared outside the target's own files
|
|
771
|
+
* belongs to another program; neither is a declaration of the target.
|
|
772
|
+
*/
|
|
773
|
+
function readTable(
|
|
774
|
+
container: Container,
|
|
775
|
+
table: ReadonlyMap<string, TSSymbol>,
|
|
776
|
+
seen: Map<string, Building>,
|
|
777
|
+
areStatic: boolean,
|
|
778
|
+
): number {
|
|
779
|
+
let outside = 0;
|
|
780
|
+
for (const [, member] of table) {
|
|
781
|
+
const declarations = member.declarations
|
|
782
|
+
.map((handle) => project.declarationAt(handle))
|
|
783
|
+
.filter((held): held is Handle<Brand> => held !== undefined);
|
|
784
|
+
if (declarations.length === 0) {
|
|
785
|
+
continue;
|
|
786
|
+
}
|
|
787
|
+
const own = declarations.filter((held) => ownFiles.has(held.node.getSourceFile().fileName));
|
|
788
|
+
if (own.length === 0) {
|
|
789
|
+
outside += declarations.length;
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
for (const held of own) {
|
|
793
|
+
keepMember(container, held.node, seen, areStatic);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return outside;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* One container's members as its own declaration writes them, for the members its
|
|
801
|
+
* symbol table does not hold: a member whose key is computed is bound to the
|
|
802
|
+
* container's type later than the table is built.
|
|
803
|
+
*/
|
|
804
|
+
function completeFromTree(container: Container, seen: Map<string, Building>): void {
|
|
805
|
+
for (const member of container.members) {
|
|
806
|
+
keepMember(container, member, seen, (modifiersOf(member) & ModifierFlags.Static) !== 0);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function keepMember(
|
|
811
|
+
container: Container,
|
|
812
|
+
node: Node,
|
|
813
|
+
seen: Map<string, Building>,
|
|
814
|
+
areStatic: boolean,
|
|
815
|
+
): void {
|
|
816
|
+
const kind = memberKindOf(container, node);
|
|
817
|
+
if (kind === undefined) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
const name = nameNodeOf(node);
|
|
821
|
+
const component = componentOf(name);
|
|
822
|
+
if (component === undefined) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const file = node.getSourceFile();
|
|
826
|
+
const key = memberKey(component, areStatic);
|
|
827
|
+
const held = seen.get(key);
|
|
828
|
+
const endLine = renderPosition(file, targetRoot, Math.max(node.end - 1, 0)).line;
|
|
829
|
+
if (held !== undefined) {
|
|
830
|
+
// A getter and a setter of one name are one symbol and one reference, so the
|
|
831
|
+
// second declaration widens the first record rather than making a second.
|
|
832
|
+
held.endLine = Math.max(held.endLine, endLine);
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
const at = name ?? node;
|
|
836
|
+
const record = keep({
|
|
837
|
+
file,
|
|
838
|
+
node,
|
|
839
|
+
module: container.owner.module,
|
|
840
|
+
position: renderPosition(file, targetRoot, at.getStart()),
|
|
841
|
+
endLine,
|
|
842
|
+
kind,
|
|
843
|
+
parentChain: chainOf(container.owner),
|
|
844
|
+
component,
|
|
845
|
+
localName: undefined,
|
|
846
|
+
parent: container.owner,
|
|
847
|
+
visibility: visibilityOf(node, name),
|
|
848
|
+
static: areStatic,
|
|
849
|
+
exported: false,
|
|
850
|
+
typeParameter: undefined,
|
|
851
|
+
});
|
|
852
|
+
seen.set(key, record);
|
|
853
|
+
declareTypeParameters(node, record);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function memberKindOf(container: Container, node: Node): SymbolKind | undefined {
|
|
857
|
+
if (container.isClass) {
|
|
858
|
+
if (
|
|
859
|
+
isPropertyDeclaration(node) ||
|
|
860
|
+
isMethodDeclaration(node) ||
|
|
861
|
+
isGetAccessorDeclaration(node) ||
|
|
862
|
+
isSetAccessorDeclaration(node)
|
|
863
|
+
) {
|
|
864
|
+
return classMemberKind(node);
|
|
865
|
+
}
|
|
866
|
+
return undefined;
|
|
867
|
+
}
|
|
868
|
+
if (container.memberKind === "enum-member") {
|
|
869
|
+
return isEnumMember(node) ? "enum-member" : undefined;
|
|
870
|
+
}
|
|
871
|
+
if (isPropertySignatureDeclaration(node) || isMethodSignatureDeclaration(node)) {
|
|
872
|
+
return typeMemberKind(node, container.memberKind === "interface-method");
|
|
873
|
+
}
|
|
874
|
+
if (isGetAccessorDeclaration(node) || isSetAccessorDeclaration(node)) {
|
|
875
|
+
return "type-member";
|
|
876
|
+
}
|
|
877
|
+
return undefined;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
const symbols = building
|
|
881
|
+
.map(render)
|
|
882
|
+
.sort((a, b) => byPosition(a.position, b.position) || (a.ref < b.ref ? -1 : 1));
|
|
883
|
+
|
|
884
|
+
return {
|
|
885
|
+
configFile: project.configFile,
|
|
886
|
+
symbols,
|
|
887
|
+
cost: { batches: 1, exportTables, memberTables },
|
|
888
|
+
starReExports,
|
|
889
|
+
outsideOwnFiles,
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** The chain of components that names one declaration, read from the module inward. */
|
|
894
|
+
function chainOf(record: Building): readonly Component[] {
|
|
895
|
+
return [...record.parentChain, record.component];
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* One declaration as the inventory reports it. The display name is the chain in the
|
|
900
|
+
* spelling a reference gives it, except where the declaration carries a name of its
|
|
901
|
+
* own the reference does not: a file, whose reference names its module, and a default
|
|
902
|
+
* export, whose reference carries its export name.
|
|
903
|
+
*/
|
|
904
|
+
function render(record: Building): InventorySymbol {
|
|
905
|
+
const chain = chainOf(record);
|
|
906
|
+
const spelled = chain
|
|
907
|
+
.map((component) =>
|
|
908
|
+
component.computed ? computedComponent(component.text) : nameComponent(component.text),
|
|
909
|
+
)
|
|
910
|
+
.join(".");
|
|
911
|
+
const name =
|
|
912
|
+
record.localName ??
|
|
913
|
+
(record.typeParameter === undefined ? spelled : `${spelled}<${record.typeParameter}>`);
|
|
914
|
+
return {
|
|
915
|
+
id: positionKey(record.position),
|
|
916
|
+
ref: refOf(record, chain),
|
|
917
|
+
name,
|
|
918
|
+
kind: record.kind,
|
|
919
|
+
position: record.position,
|
|
920
|
+
endLine: record.endLine,
|
|
921
|
+
parent: record.parent === undefined ? "" : positionKey(record.parent.position),
|
|
922
|
+
exported: record.exported,
|
|
923
|
+
visibility: record.visibility,
|
|
924
|
+
static: record.static,
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function refOf(record: Building, chain: readonly Component[]): string {
|
|
929
|
+
if (record.kind === "file") {
|
|
930
|
+
return renderRef(record.module, { of: "module" });
|
|
931
|
+
}
|
|
932
|
+
if (record.kind === "export-alias") {
|
|
933
|
+
return renderRef(record.module, { of: "alias", name: record.component.text });
|
|
934
|
+
}
|
|
935
|
+
return renderRef(record.module, {
|
|
936
|
+
of: "declaration",
|
|
937
|
+
chain,
|
|
938
|
+
static: record.static,
|
|
939
|
+
...(record.typeParameter === undefined ? {} : { typeParameter: record.typeParameter }),
|
|
940
|
+
});
|
|
941
|
+
}
|