1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import ts from 'typescript';
|
10 |
|
11 | export interface ImportManagerUpdateRecorder {
|
12 | addNewImport(start: number, importText: string): void;
|
13 | updateExistingImport(namedBindings: ts.NamedImports, newNamedBindings: string): void;
|
14 | }
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export declare class ImportManager {
|
21 | private getUpdateRecorder;
|
22 | private printer;
|
23 |
|
24 | private updatedImports;
|
25 |
|
26 | private usedIdentifierNames;
|
27 | |
28 |
|
29 |
|
30 |
|
31 | private importCache;
|
32 | constructor(getUpdateRecorder: (sf: ts.SourceFile) => ImportManagerUpdateRecorder, printer: ts.Printer);
|
33 | /**
|
34 | * Adds an import to the given source-file and returns the TypeScript
|
35 | * identifier that can be used to access the newly imported symbol.
|
36 | */
|
37 | addImportToSourceFile(sourceFile: ts.SourceFile, symbolName: string | null, moduleName: string, typeImport?: boolean): ts.Expression;
|
38 | /**
|
39 | * Stores the collected import changes within the appropriate update recorders. The
|
40 | * updated imports can only be updated *once* per source-file because previous updates
|
41 | * could otherwise shift the source-file offsets.
|
42 | */
|
43 | recordChanges(): void;
|
44 | /** Gets an unique identifier with a base name for the given source file. */
|
45 | private _getUniqueIdentifier;
|
46 | /**
|
47 | * Checks whether the specified identifier name is used within the given
|
48 | * source file.
|
49 | */
|
50 | private isUniqueIdentifierName;
|
51 | private _recordUsedIdentifier;
|
52 | /**
|
53 | * Determines the full end of a given node. By default the end position of a node is
|
54 | * before all trailing comments. This could mean that generated imports shift comments.
|
55 | */
|
56 | private _getEndPositionOfNode;
|
57 | }
|