Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix merge problems from master
  • Loading branch information
RyanCavanaugh committed Nov 9, 2015
commit e630ce247b6501d7a61ff1439ed628f63ca4ca71
11 changes: 5 additions & 6 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference path="utilities.ts"/>
/// <reference path="parser.ts"/>

/* @internal */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1154,7 +1153,7 @@ namespace ts {
case SyntaxKind.Identifier:
return checkStrictModeIdentifier(<Identifier>node);
case SyntaxKind.BinaryExpression:
if (isJavaScriptFile) {
if (isInJavaScriptFile(node)) {
if (isExportsPropertyAssignment(node)) {
bindExportsPropertyAssignment(<BinaryExpression>node);
}
Expand Down Expand Up @@ -1229,7 +1228,7 @@ namespace ts {
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);

case SyntaxKind.CallExpression:
if (isJavaScriptFile) {
if (isInJavaScriptFile(node)) {
bindCallExpression(<CallExpression>node);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the !file.commonJsModuleIndicator test into bindCallExpression so we have all the logic in one place.

}
break;
Expand Down Expand Up @@ -1275,8 +1274,8 @@ namespace ts {
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`);
}

function bindExportAssignment(node: ExportAssignment|BinaryExpression) {
let boundExpression = node.kind === SyntaxKind.ExportAssignment ? (<ExportAssignment>node).expression : (<BinaryExpression>node).right;
function bindExportAssignment(node: ExportAssignment | BinaryExpression) {
const boundExpression = node.kind === SyntaxKind.ExportAssignment ? (<ExportAssignment>node).expression : (<BinaryExpression>node).right;
if (!container.symbol || !container.symbol.exports) {
// Export assignment in some sort of block construct
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="scanner.ts"/>
/// <reference path="utilities.ts"/>
/// <reference path="scanner.ts"/>

namespace ts {
const nodeConstructors = new Array<new (pos: number, end: number) => Node>(SyntaxKind.Count);
Expand Down
22 changes: 11 additions & 11 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;
Expand All @@ -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)) {

Expand All @@ -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;
}
Expand All @@ -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 {
Expand All @@ -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 };
}
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -689,7 +689,7 @@ namespace ts {
return;
}

let isJavaScriptFile = isSourceFileJavaScript(file);
const isJavaScriptFile = isSourceFileJavaScript(file);

let imports: LiteralExpression[];
for (const node of file.statements) {
Expand Down
1 change: 0 additions & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="binder.ts" />
/// <reference path="sys.ts" />

/* @internal */
Expand Down
6 changes: 3 additions & 3 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/cases/unittests/moduleResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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",
]);
Expand Down
17 changes: 0 additions & 17 deletions tests/webTestServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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 {
Expand Down