Closed
Description
currently resolving a context for the language service requires calling ts.preProcessFile
on all files in the context, and following references. resolving triple-slash references is simple, resolving modules is a bit more complicated, as it involves searching in containing directories until a matching .ts file is found.
As a work around, here is the resolution logic:
function resolveImport(moduleName: string, souceFilename: string, fileExists: (filename: string) => boolean): string {
var searchPath = ts.getDirectoryPath(souceFilename);
while (true) {
var filename = ts.normalizePath(ts.combinePaths(searchPath, moduleName));
if (fileExists(filename + ".ts")) return filename + ".ts";
if (fileExists(filename + ".d.ts")) return filename + ".d.ts";
var parentPath = ts.getDirectoryPath(searchPath);
if (parentPath === searchPath) break;
searchPath = parentPath;
}
return undefined;
}