1 | ;
|
2 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
3 | // See LICENSE in the project root for license information.
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | exports.AstNamespaceImport = void 0;
|
6 | const AstEntity_1 = require("./AstEntity");
|
7 | /**
|
8 | * `AstNamespaceImport` represents a namespace that is created implicitly by a statement
|
9 | * such as `import * as example from "./file";`
|
10 | *
|
11 | * @remarks
|
12 | *
|
13 | * A typical input looks like this:
|
14 | * ```ts
|
15 | * // Suppose that example.ts exports two functions f1() and f2().
|
16 | * import * as example from "./file";
|
17 | * export { example };
|
18 | * ```
|
19 | *
|
20 | * API Extractor's .d.ts rollup will transform it into an explicit namespace, like this:
|
21 | * ```ts
|
22 | * declare f1(): void;
|
23 | * declare f2(): void;
|
24 | *
|
25 | * declare namespace example {
|
26 | * export {
|
27 | * f1,
|
28 | * f2
|
29 | * }
|
30 | * }
|
31 | * ```
|
32 | *
|
33 | * The current implementation does not attempt to relocate f1()/f2() to be inside the `namespace`
|
34 | * because other type signatures may reference them directly (without using the namespace qualifier).
|
35 | * The `declare namespace example` is a synthetic construct represented by `AstNamespaceImport`.
|
36 | */
|
37 | class AstNamespaceImport extends AstEntity_1.AstSyntheticEntity {
|
38 | constructor(options) {
|
39 | super();
|
40 | /**
|
41 | * Returns true if the AstSymbolTable.analyze() was called for this object.
|
42 | * See that function for details.
|
43 | */
|
44 | this.analyzed = false;
|
45 | this.astModule = options.astModule;
|
46 | this.namespaceName = options.namespaceName;
|
47 | this.declaration = options.declaration;
|
48 | }
|
49 | /** {@inheritdoc} */
|
50 | get localName() {
|
51 | // abstract
|
52 | return this.namespaceName;
|
53 | }
|
54 | fetchAstModuleExportInfo(collector) {
|
55 | const astModuleExportInfo = collector.astSymbolTable.fetchAstModuleExportInfo(this.astModule);
|
56 | return astModuleExportInfo;
|
57 | }
|
58 | }
|
59 | exports.AstNamespaceImport = AstNamespaceImport;
|
60 | //# sourceMappingURL=AstNamespaceImport.js.map |
\ | No newline at end of file |