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

Unified Diff: lib/base.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 | « no previous file | lib/declaration.ts » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/base.ts
diff --git a/lib/base.ts b/lib/base.ts
index 2f76359c57a1b216f729061a3baca9b7b5d467fd..d49b56826d2ecd98b2b089999db2c8175595d55c 100644
--- a/lib/base.ts
+++ b/lib/base.ts
@@ -10,9 +10,7 @@ import {OutputContext, Transpiler} from './main';
* where MyArray is the alias type:
* type MyArray<E> = Array<T>
*/
-export type ResolvedTypeMap = {
- [name: string]: ts.TypeNode
-};
+export type ResolvedTypeMap = Map<string, ts.TypeNode>;
/***
* Options for how TypeScript types are represented as Dart types.
@@ -67,7 +65,7 @@ export interface TypeDisplayOptions {
*/
export class ImportSummary {
showAll: boolean = false;
- shown: Set = {};
+ shown: Set<String> = new Set();
asPrefix: string;
}
@@ -75,10 +73,6 @@ export type ClassLike = ts.ClassDeclaration | ts.InterfaceDeclaration;
export type NamedDeclaration = ClassLike | ts.PropertyDeclaration | ts.VariableDeclaration |
ts.MethodDeclaration | ts.ModuleDeclaration | ts.FunctionDeclaration;
-export type Set = {
- [s: string]: boolean
-};
-
/**
* Interface extending the true InterfaceDeclaration interface to add optional state we store on
* interfaces to simplify conversion to Dart classes.
@@ -373,12 +367,12 @@ export class TranspilerBase {
}
getImportSummary(libraryUri: string): ImportSummary {
- if (!Object.hasOwnProperty.call(this.transpiler.imports, libraryUri)) {
+ if (!this.transpiler.imports.has(libraryUri)) {
let summary = new ImportSummary();
- this.transpiler.imports[libraryUri] = summary;
+ this.transpiler.imports.set(libraryUri, summary);
return summary;
}
- return this.transpiler.imports[libraryUri];
+ return this.transpiler.imports.get(libraryUri);
}
/**
@@ -387,7 +381,7 @@ export class TranspilerBase {
addImport(libraryUri: string, identifier?: string): ImportSummary {
let summary = this.getImportSummary(libraryUri);
if (identifier) {
- summary.shown[identifier] = true;
+ summary.shown.add(identifier);
} else {
summary.showAll = true;
}
@@ -434,7 +428,8 @@ export class TranspilerBase {
if (nodes) this.visitEach(nodes);
}
- visitList(nodes: ts.Node[], separator = ',') {
+ visitList(nodes: ts.Node[], separator?: string) {
+ separator = separator || ',';
for (let i = 0; i < nodes.length; i++) {
this.visit(nodes[i]);
if (i < nodes.length - 1) this.emitNoSpace(separator);
« no previous file with comments | « no previous file | lib/declaration.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698