diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 427084b577..1446ba1d45 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -709,7 +709,7 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedExtensions = [".tsx", ".ts", ".d.ts"]; + export const supportedExtensions = [".ts", ".d.ts", ".tsx"]; const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { @@ -805,4 +805,4 @@ namespace ts { Debug.assert(false, message); } } -} +} diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f429e338cf..1b16996aca 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -40,7 +40,12 @@ namespace ts { } function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { - + + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedFileName: undefined, failedLookupLocations: [] }; + } + let searchPath = getDirectoryPath(containingFile); let searchName: string; @@ -50,8 +55,13 @@ namespace ts { while (true) { searchName = normalizePath(combinePaths(searchPath, moduleName)); referencedSourceFile = forEach(supportedExtensions, extension => { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + let candidate = searchName + extension; - let ok = host.fileExists(candidate) ? candidate : undefined; if (host.fileExists(candidate)) { return candidate; }