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
Fixed linter warnings.
  • Loading branch information
rbuckton committed Feb 24, 2016
commit 72bfd2f5b6a8467c52a4e99e2fc27bab04cc532c
2 changes: 1 addition & 1 deletion src/compiler/transformers/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ namespace ts {

function visitExportDeclaration(node: ExportDeclaration): OneOrMany<Statement> {
if (contains(externalImports, node)) {
let generatedName = getGeneratedNameForNode(node);
const generatedName = getGeneratedNameForNode(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.

why does visitExportDeclaration save the result of getGeneratedNameForNode but visitImportDeclaration and visitImportEqualsDeclaration doesn't?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • visitExportDeclaration must always call getGeneratedNameForNode.
  • visitImportDeclaration calls it conditionally.
  • visitImportEqualsDeclaration doesn't call it at all.

if (node.exportClause) {
const statements: Statement[] = [];
// export { x, y } from "mod";
Expand Down
42 changes: 17 additions & 25 deletions src/compiler/transformers/module/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace ts {
let contextObjectForFile: Identifier;
let exportedLocalNames: Identifier[];
let exportedFunctionDeclarations: ExpressionStatement[];
let noSubstitution: Map<boolean> = {};
const noSubstitution: Map<boolean> = {};

return transformSourceFile;

Expand Down Expand Up @@ -992,7 +992,7 @@ namespace ts {

function hasExportedReferenceInArrayDestructuringElement(node: Expression): boolean {
if (isSpreadElementExpression(node)) {
let expression = node.expression;
const expression = node.expression;
return isIdentifier(expression) && isExportedBinding(expression);
}
else {
Expand All @@ -1002,7 +1002,7 @@ namespace ts {

function hasExportedReferenceInDestructuringElement(node: Expression): boolean {
if (isBinaryExpression(node)) {
let left = node.left;
const left = node.left;
return node.operatorToken.kind === SyntaxKind.EqualsToken
&& isDestructuringPattern(left)
&& hasExportedReferenceInDestructuringPattern(left);
Expand All @@ -1011,7 +1011,7 @@ namespace ts {
return isExportedBinding(node);
}
else if (isSpreadElementExpression(node)) {
let expression = node.expression;
const expression = node.expression;
return isIdentifier(expression) && isExportedBinding(expression);
}
else if (isDestructuringPattern(node)) {
Expand Down Expand Up @@ -1052,7 +1052,7 @@ namespace ts {
}

function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration) {
let moduleName = getExternalModuleName(importNode);
const moduleName = getExternalModuleName(importNode);
if (moduleName.kind === SyntaxKind.StringLiteral) {
return tryRenameExternalModule(<StringLiteral>moduleName)
|| getSynthesizedNode(<StringLiteral>moduleName);
Expand All @@ -1074,12 +1074,12 @@ namespace ts {
}

function getLocalNameTextForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string {
let name = getLocalNameForExternalImport(node);
const name = getLocalNameForExternalImport(node);
return name ? name.text : undefined;
}

function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): Identifier {
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.

that's weird, there are two identical declarations of this function in this review

let namespaceDeclaration = getNamespaceDeclarationNode(node);
const namespaceDeclaration = getNamespaceDeclarationNode(node);
if (namespaceDeclaration && !isDefaultImport(node)) {
return createIdentifier(getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name));
}
Expand Down Expand Up @@ -1182,8 +1182,8 @@ namespace ts {
* @param node The declaration to export.
*/
function createDeclarationExport(node: DeclarationStatement) {
let declarationName = getDeclarationName(node);
let exportName = node.flags & NodeFlags.Default ? createLiteral("default") : declarationName;
const declarationName = getDeclarationName(node);
const exportName = node.flags & NodeFlags.Default ? createLiteral("default") : declarationName;
return createExportStatement(exportName, declarationName);
}

Expand All @@ -1209,15 +1209,15 @@ namespace ts {
}

function collectDependencyGroups(externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]) {
let groupIndices: Map<number> = {};
let dependencyGroups: DependencyGroup[] = [];
for (let i = 0; i < externalImports.length; ++i) {
let externalImport = externalImports[i];
let externalModuleName = getExternalModuleNameLiteral(externalImport);
let text = externalModuleName.text;
const groupIndices: Map<number> = {};
const dependencyGroups: DependencyGroup[] = [];
for (let i = 0; i < externalImports.length; i++) {
const externalImport = externalImports[i];
const externalModuleName = getExternalModuleNameLiteral(externalImport);
const text = externalModuleName.text;
if (hasProperty(groupIndices, text)) {
// deduplicate/group entries in dependency list by the dependency name
let groupIndex = groupIndices[text];
const groupIndex = groupIndices[text];
dependencyGroups[groupIndex].externalImports.push(externalImport);
continue;
}
Expand Down Expand Up @@ -1245,14 +1245,6 @@ namespace ts {
exportedLocalNames.push(name);
}

function hoistExportedVariableDeclaration(name: Identifier) {

}

function hoistExportedFunctionDeclaration(node: FunctionDeclaration) {

}

function recordExportedFunctionDeclaration(node: FunctionDeclaration) {
if (!exportedFunctionDeclarations) {
exportedFunctionDeclarations = [];
Expand All @@ -1262,7 +1254,7 @@ namespace ts {
}

function hoistBindingElement(node: VariableDeclaration | BindingElement, isExported: boolean) {
let name = node.name;
const name = node.name;
if (isIdentifier(name)) {
hoistVariableDeclaration(getSynthesizedNode(name));
if (isExported) {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,7 @@ namespace ts {
const exportSpecifiers: Map<ExportSpecifier[]> = {};
let exportEquals: ExportAssignment = undefined;
let hasExportStars = false;
for (let node of sourceFile.statements) {
for (const node of sourceFile.statements) {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
if (!(<ImportDeclaration>node).importClause ||
Expand Down Expand Up @@ -2928,7 +2928,7 @@ namespace ts {
}

export function copyPrologueDirectives(from: Statement[], to: Statement[]): number {
for (let i = 0; i < from.length; ++i) {
for (let i = 0; i < from.length; i++) {
if (isPrologueDirective(from[i])) {
addNode(to, from[i]);
}
Expand Down