diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts
index 366ad799cd1..49b259ea695 100644
--- a/src/compiler/binder.ts
+++ b/src/compiler/binder.ts
@@ -1,3 +1,4 @@
+///
///
/* @internal */
@@ -109,8 +110,6 @@ namespace ts {
let lastContainer: Node;
let seenThisKeyword: boolean;
- const isJavaScriptFile = isSourceFileJavaScript(file);
-
// state used by reachability checks
let hasExplicitReturn: boolean;
let currentReachabilityState: Reachability;
@@ -1154,7 +1153,7 @@ namespace ts {
case SyntaxKind.Identifier:
return checkStrictModeIdentifier(node);
case SyntaxKind.BinaryExpression:
- if (isJavaScriptFile) {
+ if (isInJavaScriptFile(node)) {
if (isExportsPropertyAssignment(node)) {
bindExportsPropertyAssignment(node);
}
@@ -1229,7 +1228,7 @@ namespace ts {
return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName);
case SyntaxKind.CallExpression:
- if (isJavaScriptFile) {
+ if (isInJavaScriptFile(node)) {
bindCallExpression(node);
}
break;
@@ -1275,8 +1274,8 @@ namespace ts {
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`);
}
- function bindExportAssignment(node: ExportAssignment|BinaryExpression) {
- let boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right;
+ function bindExportAssignment(node: ExportAssignment | BinaryExpression) {
+ const boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right;
if (!container.symbol || !container.symbol.exports) {
// Export assignment in some sort of block construct
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));
diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index caff64672fe..fe406c00180 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -990,7 +990,7 @@ namespace ts {
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
- const moduleName = escapeIdentifier(moduleReferenceLiteral.text);
+ let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
if (moduleName === undefined) {
return;
@@ -3845,9 +3845,9 @@ namespace ts {
}
function resolveExternalModuleTypeByLiteral(name: StringLiteral) {
- let moduleSym = resolveExternalModuleName(name, name);
+ const moduleSym = resolveExternalModuleName(name, name);
if (moduleSym) {
- let resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
+ const resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
if (resolvedModuleSymbol) {
return getTypeOfSymbol(resolvedModuleSymbol);
}
diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts
index 894aa13cd05..5c57bfb5501 100644
--- a/src/compiler/parser.ts
+++ b/src/compiler/parser.ts
@@ -1,5 +1,5 @@
-///
///
+///
namespace ts {
const nodeConstructors = new Array Node>(SyntaxKind.Count);
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index b38ffb03859..496dcbd0d7c 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -53,13 +53,13 @@ namespace ts {
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
const failedLookupLocations: string[] = [];
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
- let resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
+ let resolvedFileName = loadNodeModuleFromFile(supportedJsExtensions, candidate, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
}
- resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
+ resolvedFileName = loadNodeModuleFromDirectory(supportedJsExtensions, candidate, failedLookupLocations, host);
return resolvedFileName
? { resolvedModule: { resolvedFileName }, failedLookupLocations }
: { resolvedModule: undefined, failedLookupLocations };
@@ -69,8 +69,8 @@ namespace ts {
}
}
- function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
- return forEach(supportedExtensions, tryLoad);
+ function loadNodeModuleFromFile(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
+ return forEach(extensions, tryLoad);
function tryLoad(ext: string): string {
const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
@@ -84,7 +84,7 @@ namespace ts {
}
}
- function loadNodeModuleFromDirectory(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
+ function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
const packageJsonPath = combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
@@ -100,7 +100,7 @@ namespace ts {
}
if (jsonContent.typings) {
- const result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
+ const result = loadNodeModuleFromFile(extensions, normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
if (result) {
return result;
}
@@ -111,7 +111,7 @@ namespace ts {
failedLookupLocation.push(packageJsonPath);
}
- return loadNodeModuleFromFile(combinePaths(candidate, "index"), failedLookupLocation, host);
+ return loadNodeModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
@@ -122,12 +122,12 @@ namespace ts {
if (baseName !== "node_modules") {
const nodeModulesFolder = combinePaths(directory, "node_modules");
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
- let result = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
+ let result = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, host);
if (result) {
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
}
- result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
+ result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, host);
if (result) {
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
}
@@ -162,7 +162,7 @@ namespace ts {
const failedLookupLocations: string[] = [];
let referencedSourceFile: string;
- let extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions;
+ const extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions;
while (true) {
searchName = normalizePath(combinePaths(searchPath, moduleName));
referencedSourceFile = forEach(extensions, extension => {
@@ -689,7 +689,7 @@ namespace ts {
return;
}
- let isJavaScriptFile = isSourceFileJavaScript(file);
+ const isJavaScriptFile = isSourceFileJavaScript(file);
let imports: LiteralExpression[];
for (const node of file.statements) {
diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts
index 956cebc8a24..a1f649f3cf8 100644
--- a/src/compiler/utilities.ts
+++ b/src/compiler/utilities.ts
@@ -1,4 +1,3 @@
-///
///
/* @internal */
diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts
index 4aa3a371b6d..1c8593a9e12 100644
--- a/src/harness/fourslash.ts
+++ b/src/harness/fourslash.ts
@@ -224,8 +224,8 @@ namespace FourSlash {
// Add input file which has matched file name with the given reference-file path.
// This is necessary when resolveReference flag is specified
private addMatchedInputFile(referenceFilePath: string, extensions: string[]) {
- let inputFiles = this.inputFiles;
- let languageServiceAdapterHost = this.languageServiceAdapterHost;
+ const inputFiles = this.inputFiles;
+ const languageServiceAdapterHost = this.languageServiceAdapterHost;
if (!extensions) {
tryAdd(referenceFilePath);
}
@@ -234,7 +234,7 @@ namespace FourSlash {
}
function tryAdd(path: string) {
- let inputFile = inputFiles[path];
+ const inputFile = inputFiles[path];
if (inputFile && !Harness.isLibraryFile(path)) {
languageServiceAdapterHost.addScript(path, inputFile);
return true;
diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts
index fb7a221b124..333cea2745d 100644
--- a/src/server/editorServices.ts
+++ b/src/server/editorServices.ts
@@ -371,7 +371,7 @@ namespace ts.server {
openRefCount = 0;
constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) {
- if(projectOptions && projectOptions.files){
+ if (projectOptions && projectOptions.files) {
// If files are listed explicitly, allow all extensions
projectOptions.compilerOptions.allowNonTsExtensions = true;
}
@@ -1321,7 +1321,7 @@ namespace ts.server {
this.setCompilerOptions(opt);
}
else {
- var defaultOpts = ts.getDefaultCompilerOptions();
+ const defaultOpts = ts.getDefaultCompilerOptions();
defaultOpts.allowNonTsExtensions = true;
this.setCompilerOptions(defaultOpts);
}
diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts
index 096f9914019..c53cad5725a 100644
--- a/tests/cases/unittests/moduleResolution.ts
+++ b/tests/cases/unittests/moduleResolution.ts
@@ -95,8 +95,8 @@ module ts {
let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile));
assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name);
assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false);
- // expect three failed lookup location - attempt to load module as file with all supported extensions
- assert.equal(resolution.failedLookupLocations.length, 3);
+ // expect five failed lookup location - attempt to load module as file with all supported extensions
+ assert.equal(resolution.failedLookupLocations.length, 5);
}
it("module name as directory - load from typings", () => {
@@ -117,6 +117,8 @@ module ts {
"/a/b/foo.ts",
"/a/b/foo.tsx",
"/a/b/foo.d.ts",
+ "/a/b/foo.js",
+ "/a/b/foo.jsx",
"/a/b/foo/index.ts",
"/a/b/foo/index.tsx",
]);
diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts
index ad9316ed04f..6bd15359e3f 100644
--- a/tests/webTestServer.ts
+++ b/tests/webTestServer.ts
@@ -263,21 +263,6 @@ http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) {
var browserPath: string;
if ((browser && browser === 'chrome')) {
-<<<<<<< HEAD
- const platform = os.platform();
- let defaultChromePath: string;
- switch(platform) {
- case "win32":
- defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe";
- break;
- case "linux":
- defaultChromePath = "/opt/google/chrome/chrome";
- break;
- default:
- console.log(`Default Chrome location for platform ${platform} is unknown`);
- break;
- }
-=======
let defaultChromePath = "";
switch (os.platform()) {
case "win32":
@@ -291,8 +276,6 @@ if ((browser && browser === 'chrome')) {
console.log(`default Chrome location is unknown for platform '${os.platform()}'`);
break;
}
-
->>>>>>> master
if (fs.existsSync(defaultChromePath)) {
browserPath = defaultChromePath;
} else {