Skip to content

Commit e630ce2

Browse files
committed
Fix merge problems from master
1 parent 7dd1bf4 commit e630ce2

File tree

9 files changed

+29
-46
lines changed

9 files changed

+29
-46
lines changed

src/compiler/binder.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference path="utilities.ts"/>
12
/// <reference path="parser.ts"/>
23

34
/* @internal */
@@ -109,8 +110,6 @@ namespace ts {
109110
let lastContainer: Node;
110111
let seenThisKeyword: boolean;
111112

112-
const isJavaScriptFile = isSourceFileJavaScript(file);
113-
114113
// state used by reachability checks
115114
let hasExplicitReturn: boolean;
116115
let currentReachabilityState: Reachability;
@@ -1154,7 +1153,7 @@ namespace ts {
11541153
case SyntaxKind.Identifier:
11551154
return checkStrictModeIdentifier(<Identifier>node);
11561155
case SyntaxKind.BinaryExpression:
1157-
if (isJavaScriptFile) {
1156+
if (isInJavaScriptFile(node)) {
11581157
if (isExportsPropertyAssignment(node)) {
11591158
bindExportsPropertyAssignment(<BinaryExpression>node);
11601159
}
@@ -1229,7 +1228,7 @@ namespace ts {
12291228
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
12301229

12311230
case SyntaxKind.CallExpression:
1232-
if (isJavaScriptFile) {
1231+
if (isInJavaScriptFile(node)) {
12331232
bindCallExpression(<CallExpression>node);
12341233
}
12351234
break;
@@ -1275,8 +1274,8 @@ namespace ts {
12751274
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`);
12761275
}
12771276

1278-
function bindExportAssignment(node: ExportAssignment|BinaryExpression) {
1279-
let boundExpression = node.kind === SyntaxKind.ExportAssignment ? (<ExportAssignment>node).expression : (<BinaryExpression>node).right;
1277+
function bindExportAssignment(node: ExportAssignment | BinaryExpression) {
1278+
const boundExpression = node.kind === SyntaxKind.ExportAssignment ? (<ExportAssignment>node).expression : (<BinaryExpression>node).right;
12801279
if (!container.symbol || !container.symbol.exports) {
12811280
// Export assignment in some sort of block construct
12821281
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ namespace ts {
990990

991991
// Module names are escaped in our symbol table. However, string literal values aren't.
992992
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
993-
const moduleName = escapeIdentifier(moduleReferenceLiteral.text);
993+
let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
994994

995995
if (moduleName === undefined) {
996996
return;
@@ -3845,9 +3845,9 @@ namespace ts {
38453845
}
38463846

38473847
function resolveExternalModuleTypeByLiteral(name: StringLiteral) {
3848-
let moduleSym = resolveExternalModuleName(name, name);
3848+
const moduleSym = resolveExternalModuleName(name, name);
38493849
if (moduleSym) {
3850-
let resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
3850+
const resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
38513851
if (resolvedModuleSymbol) {
38523852
return getTypeOfSymbol(resolvedModuleSymbol);
38533853
}

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// <reference path="scanner.ts"/>
21
/// <reference path="utilities.ts"/>
2+
/// <reference path="scanner.ts"/>
33

44
namespace ts {
55
const nodeConstructors = new Array<new (pos: number, end: number) => Node>(SyntaxKind.Count);

src/compiler/program.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ namespace ts {
5353
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
5454
const failedLookupLocations: string[] = [];
5555
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
56-
let resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
56+
let resolvedFileName = loadNodeModuleFromFile(supportedJsExtensions, candidate, failedLookupLocations, host);
5757

5858
if (resolvedFileName) {
5959
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
6060
}
6161

62-
resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
62+
resolvedFileName = loadNodeModuleFromDirectory(supportedJsExtensions, candidate, failedLookupLocations, host);
6363
return resolvedFileName
6464
? { resolvedModule: { resolvedFileName }, failedLookupLocations }
6565
: { resolvedModule: undefined, failedLookupLocations };
@@ -69,8 +69,8 @@ namespace ts {
6969
}
7070
}
7171

72-
function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
73-
return forEach(supportedExtensions, tryLoad);
72+
function loadNodeModuleFromFile(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
73+
return forEach(extensions, tryLoad);
7474

7575
function tryLoad(ext: string): string {
7676
const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
@@ -84,7 +84,7 @@ namespace ts {
8484
}
8585
}
8686

87-
function loadNodeModuleFromDirectory(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
87+
function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
8888
const packageJsonPath = combinePaths(candidate, "package.json");
8989
if (host.fileExists(packageJsonPath)) {
9090

@@ -100,7 +100,7 @@ namespace ts {
100100
}
101101

102102
if (jsonContent.typings) {
103-
const result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
103+
const result = loadNodeModuleFromFile(extensions, normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
104104
if (result) {
105105
return result;
106106
}
@@ -111,7 +111,7 @@ namespace ts {
111111
failedLookupLocation.push(packageJsonPath);
112112
}
113113

114-
return loadNodeModuleFromFile(combinePaths(candidate, "index"), failedLookupLocation, host);
114+
return loadNodeModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocation, host);
115115
}
116116

117117
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
@@ -122,12 +122,12 @@ namespace ts {
122122
if (baseName !== "node_modules") {
123123
const nodeModulesFolder = combinePaths(directory, "node_modules");
124124
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
125-
let result = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
125+
let result = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, host);
126126
if (result) {
127127
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
128128
}
129129

130-
result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
130+
result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, host);
131131
if (result) {
132132
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
133133
}
@@ -162,7 +162,7 @@ namespace ts {
162162
const failedLookupLocations: string[] = [];
163163

164164
let referencedSourceFile: string;
165-
let extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions;
165+
const extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions;
166166
while (true) {
167167
searchName = normalizePath(combinePaths(searchPath, moduleName));
168168
referencedSourceFile = forEach(extensions, extension => {
@@ -689,7 +689,7 @@ namespace ts {
689689
return;
690690
}
691691

692-
let isJavaScriptFile = isSourceFileJavaScript(file);
692+
const isJavaScriptFile = isSourceFileJavaScript(file);
693693

694694
let imports: LiteralExpression[];
695695
for (const node of file.statements) {

src/compiler/utilities.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference path="binder.ts" />
21
/// <reference path="sys.ts" />
32

43
/* @internal */

src/harness/fourslash.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ namespace FourSlash {
224224
// Add input file which has matched file name with the given reference-file path.
225225
// This is necessary when resolveReference flag is specified
226226
private addMatchedInputFile(referenceFilePath: string, extensions: string[]) {
227-
let inputFiles = this.inputFiles;
228-
let languageServiceAdapterHost = this.languageServiceAdapterHost;
227+
const inputFiles = this.inputFiles;
228+
const languageServiceAdapterHost = this.languageServiceAdapterHost;
229229
if (!extensions) {
230230
tryAdd(referenceFilePath);
231231
}
@@ -234,7 +234,7 @@ namespace FourSlash {
234234
}
235235

236236
function tryAdd(path: string) {
237-
let inputFile = inputFiles[path];
237+
const inputFile = inputFiles[path];
238238
if (inputFile && !Harness.isLibraryFile(path)) {
239239
languageServiceAdapterHost.addScript(path, inputFile);
240240
return true;

src/server/editorServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ namespace ts.server {
371371
openRefCount = 0;
372372

373373
constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) {
374-
if(projectOptions && projectOptions.files){
374+
if (projectOptions && projectOptions.files) {
375375
// If files are listed explicitly, allow all extensions
376376
projectOptions.compilerOptions.allowNonTsExtensions = true;
377377
}
@@ -1321,7 +1321,7 @@ namespace ts.server {
13211321
this.setCompilerOptions(opt);
13221322
}
13231323
else {
1324-
var defaultOpts = ts.getDefaultCompilerOptions();
1324+
const defaultOpts = ts.getDefaultCompilerOptions();
13251325
defaultOpts.allowNonTsExtensions = true;
13261326
this.setCompilerOptions(defaultOpts);
13271327
}

tests/cases/unittests/moduleResolution.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ module ts {
9595
let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile));
9696
assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name);
9797
assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false);
98-
// expect three failed lookup location - attempt to load module as file with all supported extensions
99-
assert.equal(resolution.failedLookupLocations.length, 3);
98+
// expect five failed lookup location - attempt to load module as file with all supported extensions
99+
assert.equal(resolution.failedLookupLocations.length, 5);
100100
}
101101

102102
it("module name as directory - load from typings", () => {
@@ -117,6 +117,8 @@ module ts {
117117
"/a/b/foo.ts",
118118
"/a/b/foo.tsx",
119119
"/a/b/foo.d.ts",
120+
"/a/b/foo.js",
121+
"/a/b/foo.jsx",
120122
"/a/b/foo/index.ts",
121123
"/a/b/foo/index.tsx",
122124
]);

tests/webTestServer.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -263,21 +263,6 @@ http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) {
263263

264264
var browserPath: string;
265265
if ((browser && browser === 'chrome')) {
266-
<<<<<<< HEAD
267-
const platform = os.platform();
268-
let defaultChromePath: string;
269-
switch(platform) {
270-
case "win32":
271-
defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe";
272-
break;
273-
case "linux":
274-
defaultChromePath = "/opt/google/chrome/chrome";
275-
break;
276-
default:
277-
console.log(`Default Chrome location for platform ${platform} is unknown`);
278-
break;
279-
}
280-
=======
281266
let defaultChromePath = "";
282267
switch (os.platform()) {
283268
case "win32":
@@ -291,8 +276,6 @@ if ((browser && browser === 'chrome')) {
291276
console.log(`default Chrome location is unknown for platform '${os.platform()}'`);
292277
break;
293278
}
294-
295-
>>>>>>> master
296279
if (fs.existsSync(defaultChromePath)) {
297280
browserPath = defaultChromePath;
298281
} else {

0 commit comments

Comments
 (0)