From d4b88899840edd218ae2638538aebcaf7b13c15c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 31 May 2016 12:58:05 -0700 Subject: [PATCH] Respond to more PR comments --- src/compiler/core.ts | 7 ------- src/compiler/program.ts | 9 +++++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 932acdc6324..ba81ee7d103 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -861,13 +861,6 @@ namespace ts { return fileExtensionIs(path, extension) ? path.substring(0, path.length - extension.length) : undefined; } - export function getFileExtension(path: string): string { - const dot = path.lastIndexOf("."); - if (dot !== -1) { - return path.substring(dot); - } - } - export interface ObjectAllocator { getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c7b2cd66caf..dd3102410ef 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -620,9 +620,9 @@ namespace ts { */ function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { // First try to keep/add an extension: importing "./foo.ts" can be matched by a file "./foo.ts", and "./foo" by "./foo.d.ts" - const keepOrAddExtension = loadModuleFromFileWorker(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (keepOrAddExtension) { - return keepOrAddExtension; + const resolvedByAddingOrKeepingExtension = loadModuleFromFileWorker(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingOrKeepingExtension) { + return resolvedByAddingOrKeepingExtension; } // Then try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one, e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJavaScriptFileExtension(candidate)) { @@ -634,9 +634,10 @@ namespace ts { return loadModuleFromFileWorker(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); } } + function loadModuleFromFileWorker(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { if (!onlyRecordFailures) { - // check if containig folder exists - if it doesn't then just record failures for all supported extensions without disk probing + // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing const directory = getDirectoryPath(candidate); if (directory) { onlyRecordFailures = !directoryProbablyExists(directory, state.host);