1 | import { AstSymbol } from './AstSymbol';
|
2 | import { AstSyntheticEntity } from './AstEntity';
|
3 | /**
|
4 | * Indicates the import kind for an `AstImport`.
|
5 | */
|
6 | export declare enum AstImportKind {
|
7 | /**
|
8 | * An import statement such as `import X from "y";`.
|
9 | */
|
10 | DefaultImport = 0,
|
11 | /**
|
12 | * An import statement such as `import { X } from "y";`.
|
13 | */
|
14 | NamedImport = 1,
|
15 | /**
|
16 | * An import statement such as `import * as x from "y";`.
|
17 | */
|
18 | StarImport = 2,
|
19 | /**
|
20 | * An import statement such as `import x = require("y");`.
|
21 | */
|
22 | EqualsImport = 3,
|
23 | /**
|
24 | * An import statement such as `interface foo { foo: import("bar").a.b.c }`.
|
25 | */
|
26 | ImportType = 4
|
27 | }
|
28 | /**
|
29 | * Constructor parameters for AstImport
|
30 | *
|
31 | * @privateRemarks
|
32 | * Our naming convention is to use I____Parameters for constructor options and
|
33 | * I____Options for general function options. However the word "parameters" is
|
34 | * confusingly similar to the terminology for function parameters modeled by API Extractor,
|
35 | * so we use I____Options for both cases in this code base.
|
36 | */
|
37 | export interface IAstImportOptions {
|
38 | readonly importKind: AstImportKind;
|
39 | readonly modulePath: string;
|
40 | readonly exportName: string;
|
41 | readonly isTypeOnly: boolean;
|
42 | }
|
43 | /**
|
44 | * For a symbol that was imported from an external package, this tracks the import
|
45 | * statement that was used to reach it.
|
46 | */
|
47 | export declare class AstImport extends AstSyntheticEntity {
|
48 | readonly importKind: AstImportKind;
|
49 | /**
|
50 | * The name of the external package (and possibly module path) that this definition
|
51 | * was imported from.
|
52 | *
|
53 | * Example: "@rushstack/node-core-library/lib/FileSystem"
|
54 | */
|
55 | readonly modulePath: string;
|
56 | /**
|
57 | * The name of the symbol being imported.
|
58 | *
|
59 | * @remarks
|
60 | *
|
61 | * The name depends on the type of import:
|
62 | *
|
63 | * ```ts
|
64 | * // For AstImportKind.DefaultImport style, exportName would be "X" in this example:
|
65 | * import X from "y";
|
66 | *
|
67 | * // For AstImportKind.NamedImport style, exportName would be "X" in this example:
|
68 | * import { X } from "y";
|
69 | *
|
70 | * // For AstImportKind.StarImport style, exportName would be "x" in this example:
|
71 | * import * as x from "y";
|
72 | *
|
73 | * // For AstImportKind.EqualsImport style, exportName would be "x" in this example:
|
74 | * import x = require("y");
|
75 | *
|
76 | * // For AstImportKind.ImportType style, exportName would be "a.b.c" in this example:
|
77 | * interface foo { foo: import('bar').a.b.c };
|
78 | * ```
|
79 | */
|
80 | readonly exportName: string;
|
81 | /**
|
82 | * Whether it is a type-only import, for example:
|
83 | *
|
84 | * ```ts
|
85 | * import type { X } from "y";
|
86 | * ```
|
87 | *
|
88 | * This is set to true ONLY if the type-only form is used in *every* reference to this AstImport.
|
89 | */
|
90 | isTypeOnlyEverywhere: boolean;
|
91 | /**
|
92 | * If this import statement refers to an API from an external package that is tracked by API Extractor
|
93 | * (according to `PackageMetadataManager.isAedocSupportedFor()`), then this property will return the
|
94 | * corresponding AstSymbol. Otherwise, it is undefined.
|
95 | */
|
96 | astSymbol: AstSymbol | undefined;
|
97 | /**
|
98 | * If modulePath and exportName are defined, then this is a dictionary key
|
99 | * that combines them with a colon (":").
|
100 | *
|
101 | * Example: "@rushstack/node-core-library/lib/FileSystem:FileSystem"
|
102 | */
|
103 | readonly key: string;
|
104 | constructor(options: IAstImportOptions);
|
105 | /** {@inheritdoc} */
|
106 | get localName(): string;
|
107 | /**
|
108 | * Calculates the lookup key used with `AstImport.key`
|
109 | */
|
110 | static getKey(options: IAstImportOptions): string;
|
111 | }
|
112 | //# sourceMappingURL=AstImport.d.ts.map |
\ | No newline at end of file |