(moduleName, containingFile, compilerOptions, host, cache, redirectedReference)
| 44464 | } |
| 44465 | } |
| 44466 | function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { |
| 44467 | var traceEnabled = isTraceEnabled(compilerOptions, host); |
| 44468 | var failedLookupLocations = []; |
| 44469 | var containingDirectory = ts.getDirectoryPath(containingFile); |
| 44470 | var diagnostics = []; |
| 44471 | var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; |
| 44472 | var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); |
| 44473 | // No originalPath because classic resolution doesn't resolve realPath |
| 44474 | return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache); |
| 44475 | function tryResolve(extensions) { |
| 44476 | var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); |
| 44477 | if (resolvedUsingSettings) { |
| 44478 | return { value: resolvedUsingSettings }; |
| 44479 | } |
| 44480 | if (!ts.isExternalModuleNameRelative(moduleName)) { |
| 44481 | var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference); |
| 44482 | // Climb up parent directories looking for a module. |
| 44483 | var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { |
| 44484 | var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); |
| 44485 | if (resolutionFromCache) { |
| 44486 | return resolutionFromCache; |
| 44487 | } |
| 44488 | var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); |
| 44489 | return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, /*onlyRecordFailures*/ false, state)); |
| 44490 | }); |
| 44491 | if (resolved_3) { |
| 44492 | return resolved_3; |
| 44493 | } |
| 44494 | if (extensions === Extensions.TypeScript) { |
| 44495 | // If we didn't find the file normally, look it up in @types. |
| 44496 | return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state); |
| 44497 | } |
| 44498 | } |
| 44499 | else { |
| 44500 | var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); |
| 44501 | return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, /*onlyRecordFailures*/ false, state)); |
| 44502 | } |
| 44503 | } |
| 44504 | } |
| 44505 | ts.classicNameResolver = classicNameResolver; |
| 44506 | /** |
| 44507 | * A host may load a module from a global cache of typings. |
no test coverage detected
searching dependent graphs…