Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(975)

Unified Diff: lib/main.ts

Issue 2416003003: Update package name, update and lock clang-format and tslint versions, and format all source files … (Closed)
Patch Set: Use ES6 Map and Set instead of Object literals to avoid ordering instability across different Node … Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/facade_converter.ts ('k') | lib/merge.ts » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/main.ts
diff --git a/lib/main.ts b/lib/main.ts
index e9919c37eb8196edf55232c32bb69021ca225591..515059b8264710415116861d2ab8609d85949b91 100644
--- a/lib/main.ts
+++ b/lib/main.ts
@@ -2,7 +2,6 @@ import * as dartStyle from 'dart-style';
import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
-
import * as base from './base';
import {ImportSummary, TranspilerBase} from './base';
import DeclarationTranspiler from './declaration';
@@ -74,7 +73,7 @@ export class Transpiler {
/**
* Map of import library path to a Set of identifier names being imported.
*/
- imports: ts.Map<ImportSummary>;
+ imports: Map<String, ImportSummary>;
// Comments attach to all following AST nodes before the next 'physical' token. Track the earliest
// offset to avoid printing comments multiple times.
private lastCommentIdx: number = -1;
@@ -86,7 +85,8 @@ export class Transpiler {
/* Number of nested levels of type arguments the current expression is within. */
private typeArgumentDepth = 0;
- constructor(private options: TranspilerOptions = {}) {
+ constructor(private options: TranspilerOptions) {
+ this.options = this.options || {};
this.fc = new FacadeConverter(this, options.typingsRoot);
this.declarationTranspiler = new DeclarationTranspiler(
this, this.fc, options.enforceUnderscoreConventions, options.promoteFunctionLikeMembers);
@@ -237,7 +237,7 @@ export class Transpiler {
this.currentFile = sourceFile;
this.outputs = [];
this.outputStack = [];
- this.imports = {};
+ this.imports = new Map();
for (let i = 0; i < NUM_OUTPUT_CONTEXTS; ++i) {
this.outputs.push(new Output());
}
@@ -254,12 +254,11 @@ export class Transpiler {
}
this.pushContext(OutputContext.Import);
- for (let name of Object.getOwnPropertyNames(this.imports)) {
- let summary = this.imports[name];
+ this.imports.forEach((summary, name) => {
this.emit(`import ${JSON.stringify(name)}`);
if (!summary.showAll) {
- let shownNames = Object.getOwnPropertyNames(summary.shown);
+ let shownNames = Array.from(summary.shown);
if (shownNames.length > 0) {
this.emit(`show ${shownNames.join(', ')}`);
}
@@ -268,7 +267,7 @@ export class Transpiler {
this.emit(`as ${summary.asPrefix}`);
}
this.emit(';\n');
- }
+ });
this.popContext();
let result = '';
« no previous file with comments | « lib/facade_converter.ts ('k') | lib/merge.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698