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:
functionresolveImport(moduleName: string,souceFilename: string,fileExists: (filename: string)=>boolean): string{varsearchPath=ts.getDirectoryPath(souceFilename);while(true){varfilename=ts.normalizePath(ts.combinePaths(searchPath,moduleName));if(fileExists(filename+".ts"))returnfilename+".ts";if(fileExists(filename+".d.ts"))returnfilename+".d.ts";varparentPath=ts.getDirectoryPath(searchPath);if(parentPath===searchPath)break;searchPath=parentPath;}returnundefined;}
currently resolving a context for the language service requires calling
ts.preProcessFileon 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: