From a0277f1b3a47474074b1a96c4e509f5e2bd43dd9 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 6 Oct 2015 19:05:09 -0700 Subject: [PATCH] refactor: add missing types for ts2dart Closes #4568 --- .../render_view_with_fragments_store.ts | 2 +- .../change_detection/parser/parser_spec.ts | 9 ++--- .../src/reporter/console_reporter.ts | 2 +- .../benchpress/src/reporter/multi_reporter.ts | 1 - .../test/metric/multi_metric_spec.ts | 2 +- .../test/reporter/multi_reporter_spec.ts | 3 +- .../test/web_driver_extension_spec.ts | 3 +- modules/examples/src/routing/inbox-app.ts | 33 ++++++++++++------- 8 files changed, 32 insertions(+), 23 deletions(-) diff --git a/modules/angular2/src/web_workers/shared/render_view_with_fragments_store.ts b/modules/angular2/src/web_workers/shared/render_view_with_fragments_store.ts index df75e5f8c7..74da2b69aa 100644 --- a/modules/angular2/src/web_workers/shared/render_view_with_fragments_store.ts +++ b/modules/angular2/src/web_workers/shared/render_view_with_fragments_store.ts @@ -136,7 +136,7 @@ export class RenderViewWithFragmentsStore { } var viewRef = this.deserializeRenderViewRef(obj['viewRef']); - var fragments = obj['fragmentRefs'].map(val => this.deserializeRenderFragmentRef(val)); + var fragments = (obj['fragmentRefs']).map(val => this.deserializeRenderFragmentRef(val)); return new RenderViewWithFragments(viewRef, fragments); } diff --git a/modules/angular2/test/core/change_detection/parser/parser_spec.ts b/modules/angular2/test/core/change_detection/parser/parser_spec.ts index 861318966e..d4ee012ba5 100644 --- a/modules/angular2/test/core/change_detection/parser/parser_spec.ts +++ b/modules/angular2/test/core/change_detection/parser/parser_spec.ts @@ -1,7 +1,6 @@ import {ddescribe, describe, it, xit, iit, expect, beforeEach} from 'angular2/test_lib'; import {isBlank, isPresent} from 'angular2/src/core/facade/lang'; import {reflector} from 'angular2/src/core/reflection/reflection'; -import {MapWrapper} from 'angular2/src/core/facade/collection'; import {Parser} from 'angular2/src/core/change_detection/parser/parser'; import {Unparser} from './unparser'; import {Lexer} from 'angular2/src/core/change_detection/parser/lexer'; @@ -270,9 +269,11 @@ export function main() { describe('parseTemplateBindings', () => { - function keys(templateBindings) { return templateBindings.map(binding => binding.key); } + function keys(templateBindings: any[]) { + return templateBindings.map(binding => binding.key); + } - function keyValues(templateBindings) { + function keyValues(templateBindings: any[]) { return templateBindings.map(binding => { if (binding.keyIsVar) { return '#' + binding.key + (isBlank(binding.name) ? '=null' : '=' + binding.name); @@ -282,7 +283,7 @@ export function main() { }); } - function exprSources(templateBindings) { + function exprSources(templateBindings: any[]) { return templateBindings.map( binding => isPresent(binding.expression) ? binding.expression.source : null); } diff --git a/modules/benchpress/src/reporter/console_reporter.ts b/modules/benchpress/src/reporter/console_reporter.ts index cd817c3bc4..03445076cb 100644 --- a/modules/benchpress/src/reporter/console_reporter.ts +++ b/modules/benchpress/src/reporter/console_reporter.ts @@ -85,7 +85,7 @@ export class ConsoleReporter extends Reporter { return PromiseWrapper.resolve(null); } - _printStringRow(parts, fill = ' ') { + _printStringRow(parts: any[], fill = ' ') { this._print( parts.map(part => ConsoleReporter._lpad(part, this._columnWidth, fill)).join(' | ')); } diff --git a/modules/benchpress/src/reporter/multi_reporter.ts b/modules/benchpress/src/reporter/multi_reporter.ts index d452145709..4d27dd1da6 100644 --- a/modules/benchpress/src/reporter/multi_reporter.ts +++ b/modules/benchpress/src/reporter/multi_reporter.ts @@ -1,5 +1,4 @@ import {bind, Binding, Injector, OpaqueToken} from 'angular2/src/core/di'; -import {ListWrapper} from 'angular2/src/core/facade/collection'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; import {MeasureValues} from '../measure_values'; diff --git a/modules/benchpress/test/metric/multi_metric_spec.ts b/modules/benchpress/test/metric/multi_metric_spec.ts index 5ac84ff042..69a9d87674 100644 --- a/modules/benchpress/test/metric/multi_metric_spec.ts +++ b/modules/benchpress/test/metric/multi_metric_spec.ts @@ -17,7 +17,7 @@ import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async'; import {Metric, MultiMetric, bind, Injector} from 'benchpress/common'; export function main() { - function createMetric(ids) { + function createMetric(ids: any[]) { var m = Injector.resolveAndCreate([ ids.map(id => bind(id).toValue(new MockMetric(id))), MultiMetric.createBindings(ids) diff --git a/modules/benchpress/test/reporter/multi_reporter_spec.ts b/modules/benchpress/test/reporter/multi_reporter_spec.ts index 47e99fede1..ec37ee1b06 100644 --- a/modules/benchpress/test/reporter/multi_reporter_spec.ts +++ b/modules/benchpress/test/reporter/multi_reporter_spec.ts @@ -11,14 +11,13 @@ import { xit, } from 'angular2/test_lib'; -import {ListWrapper} from 'angular2/src/core/facade/collection'; import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async'; import {DateWrapper} from 'angular2/src/core/facade/lang'; import {Reporter, MultiReporter, bind, Injector, MeasureValues} from 'benchpress/common'; export function main() { - function createReporters(ids) { + function createReporters(ids: any[]) { var r = Injector.resolveAndCreate([ ids.map(id => bind(id).toValue(new MockReporter(id))), MultiReporter.createBindings(ids) diff --git a/modules/benchpress/test/web_driver_extension_spec.ts b/modules/benchpress/test/web_driver_extension_spec.ts index acdd0c12fd..4f09b2337b 100644 --- a/modules/benchpress/test/web_driver_extension_spec.ts +++ b/modules/benchpress/test/web_driver_extension_spec.ts @@ -11,14 +11,13 @@ import { xit, } from 'angular2/test_lib'; -import {ListWrapper} from 'angular2/src/core/facade/collection'; import {isPresent, StringWrapper} from 'angular2/src/core/facade/lang'; import {PromiseWrapper} from 'angular2/src/core/facade/async'; import {WebDriverExtension, bind, Injector, Options} from 'benchpress/common'; export function main() { - function createExtension(ids, caps) { + function createExtension(ids: any[], caps) { return PromiseWrapper.wrap(() => { return Injector.resolveAndCreate([ ids.map(id => bind(id).toValue(new MockExtension(id))), diff --git a/modules/examples/src/routing/inbox-app.ts b/modules/examples/src/routing/inbox-app.ts index 9382c42b26..bf8284c049 100644 --- a/modules/examples/src/routing/inbox-app.ts +++ b/modules/examples/src/routing/inbox-app.ts @@ -13,11 +13,6 @@ import {ObservableWrapper, PromiseWrapper, Promise} from 'angular2/src/core/faca import {ListWrapper} from 'angular2/src/core/facade/collection'; import {isPresent} from 'angular2/src/core/facade/lang'; -interface RecordData { - id: string, subject: string, content: string, email: string, firstName: string, lastName: string, - date: string, draft?: boolean -} - class InboxRecord { id: string = ''; subject: string = ''; @@ -28,13 +23,29 @@ class InboxRecord { date: string = ''; draft: boolean = false; - constructor(data: RecordData = null) { + constructor(data: { + id: string, + subject: string, + content: string, + email: string, + firstName: string, + lastName: string, + date: string, draft?: boolean + } = null) { if (isPresent(data)) { this.setData(data); } } - setData(record: RecordData) { + setData(record: { + id: string, + subject: string, + content: string, + email: string, + firstName: string, + lastName: string, + date: string, draft?: boolean + }) { this.id = record['id']; this.subject = record['subject']; this.content = record['content']; @@ -48,26 +59,26 @@ class InboxRecord { @Injectable() class DbService { - getData(): Promise { + getData(): Promise { var p = PromiseWrapper.completer(); p.resolve(db.data); return p.promise; } - drafts(): Promise { + drafts(): Promise { return PromiseWrapper.then(this.getData(), (data) => { return ListWrapper.filter(data, (record => isPresent(record['draft']) && record['draft'] == true)); }); } - emails(): Promise { + emails(): Promise { return PromiseWrapper.then(this.getData(), (data) => { return ListWrapper.filter(data, (record => !isPresent(record['draft']))); }); } - email(id): Promise { + email(id): Promise { return PromiseWrapper.then(this.getData(), (data) => { for (var i = 0; i < data.length; i++) { var entry = data[i];