diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts
new file mode 100644
index 0000000000..f92464e5a3
--- /dev/null
+++ b/src/compiler/resolutionCache.ts
@@ -0,0 +1,198 @@
+///
+///
+
+namespace ts {
+ export interface ResolutionCache {
+ setModuleResolutionHost(host: ModuleResolutionHost): void;
+ startRecordingFilesWithChangedResolutions(): void;
+ finishRecordingFilesWithChangedResolutions(): Path[];
+ resolveModuleNames(moduleNames: string[], containingFile: string, logChanges: boolean): ResolvedModuleFull[];
+ resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
+ invalidateResolutionOfDeletedFile(filePath: Path): void;
+ clear(): void;
+ }
+
+ type NameResolutionWithFailedLookupLocations = { failedLookupLocations: string[], isInvalidated?: boolean };
+ type ResolverWithGlobalCache = (primaryResult: ResolvedModuleWithFailedLookupLocations, moduleName: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost) => ResolvedModuleWithFailedLookupLocations | undefined;
+
+ /*@internal*/
+ export function resolveWithGlobalCache(primaryResult: ResolvedModuleWithFailedLookupLocations, moduleName: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string | undefined, projectName: string): ResolvedModuleWithFailedLookupLocations | undefined {
+ if (!isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) {
+ // otherwise try to load typings from @types
+
+ // create different collection of failed lookup locations for second pass
+ // if it will fail and we've already found something during the first pass - we don't want to pollute its results
+ const { resolvedModule, failedLookupLocations } = loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache);
+ if (resolvedModule) {
+ return { resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) };
+ }
+ }
+ }
+
+ /*@internal*/
+ export function createResolutionCache(
+ toPath: (fileName: string) => Path,
+ getCompilerOptions: () => CompilerOptions,
+ resolveWithGlobalCache?: ResolverWithGlobalCache): ResolutionCache {
+
+ let host: ModuleResolutionHost;
+ let filesWithChangedSetOfUnresolvedImports: Path[];
+ const resolvedModuleNames = createMap