UNPKG

1.78 kBTypeScriptView Raw
1import * as dependentFilesUtils from './get-dependent-files';
2import { Change } from './change';
3import { Host } from '../lib/ast-tools';
4/**
5 * Rewrites import module of dependent files when the file is moved.
6 * Also, rewrites export module of related index file of the given file.
7 */
8export declare class ModuleResolver {
9 oldFilePath: string;
10 newFilePath: string;
11 rootPath: string;
12 constructor(oldFilePath: string, newFilePath: string, rootPath: string);
13 /**
14 * Changes are applied from the bottom of a file to the top.
15 * An array of Change instances are sorted based upon the order,
16 * then apply() method is called sequentially.
17 *
18 * @param changes {Change []}
19 * @param host {Host}
20 * @return Promise after all apply() method of Change class is called
21 * to all Change instances sequentially.
22 */
23 applySortedChangePromise(changes: Change[], host?: Host): Promise<void>;
24 /**
25 * Assesses the import specifier and determines if it is a relative import.
26 *
27 * @return {boolean} boolean value if the import specifier is a relative import.
28 */
29 isRelativeImport(importClause: dependentFilesUtils.ModuleImport): boolean;
30 /**
31 * Rewrites the import specifiers of all the dependent files (cases for no index file).
32 *
33 * @todo Implement the logic for rewriting imports of the dependent files when the file
34 * being moved has index file in its old path and/or in its new path.
35 *
36 * @return {Promise<Change[]>}
37 */
38 resolveDependentFiles(): Promise<Change[]>;
39 /**
40 * Rewrites the file's own relative imports after it has been moved to new path.
41 *
42 * @return {Promise<Change[]>}
43 */
44 resolveOwnImports(): Promise<Change[]>;
45}