diff --git a/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html b/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html index 6495d6616e..4b63578193 100644 --- a/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html +++ b/docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html @@ -2,7 +2,6 @@ {% block staticDeclarations %} interface Map {} -interface StringMap extends Map {} {% for alias, module in doc.moduleDocs %} declare module {$ module.namespace $} { diff --git a/modules/angular2/manual_typings/globals.d.ts b/modules/angular2/manual_typings/globals.d.ts index fb9ab8e2f9..a725c17c3d 100644 --- a/modules/angular2/manual_typings/globals.d.ts +++ b/modules/angular2/manual_typings/globals.d.ts @@ -5,10 +5,6 @@ /// declare var assert: any; -// FIXME: K must be string! -// FIXME: should have an index signature, `[k: string]: V;` -interface StringMap {} - interface BrowserNodeGlobal { Object: typeof Object; Array: typeof Array; diff --git a/modules/angular2/src/animate/animation.ts b/modules/angular2/src/animate/animation.ts index b328beaca6..b70bf27023 100644 --- a/modules/angular2/src/animate/animation.ts +++ b/modules/angular2/src/animate/animation.ts @@ -96,7 +96,7 @@ export class Animation { * Applies the provided styles to the element * @param styles */ - applyStyles(styles: StringMap): void { + applyStyles(styles: {[key: string]: any}): void { StringMapWrapper.forEach(styles, (value, key) => { var dashCaseKey = camelCaseToDashCase(key); if (isPresent(DOM.getStyle(this.element, dashCaseKey))) { diff --git a/modules/angular2/src/animate/css_animation_builder.ts b/modules/angular2/src/animate/css_animation_builder.ts index 1b5a4e73fc..502d7f64a5 100644 --- a/modules/angular2/src/animate/css_animation_builder.ts +++ b/modules/angular2/src/animate/css_animation_builder.ts @@ -61,7 +61,7 @@ export class CssAnimationBuilder { * @param from * @param to */ - setStyles(from: StringMap, to: StringMap): CssAnimationBuilder { + setStyles(from: {[key: string]: any}, to: {[key: string]: any}): CssAnimationBuilder { return this.setFromStyles(from).setToStyles(to); } @@ -69,7 +69,7 @@ export class CssAnimationBuilder { * Sets the initial styles for the animation * @param from */ - setFromStyles(from: StringMap): CssAnimationBuilder { + setFromStyles(from: {[key: string]: any}): CssAnimationBuilder { this.data.fromStyles = from; return this; } @@ -78,7 +78,7 @@ export class CssAnimationBuilder { * Sets the destination styles for the animation * @param to */ - setToStyles(to: StringMap): CssAnimationBuilder { + setToStyles(to: {[key: string]: any}): CssAnimationBuilder { this.data.toStyles = to; return this; } diff --git a/modules/angular2/src/animate/css_animation_options.ts b/modules/angular2/src/animate/css_animation_options.ts index 6fcb9e8f4f..eab07b893a 100644 --- a/modules/angular2/src/animate/css_animation_options.ts +++ b/modules/angular2/src/animate/css_animation_options.ts @@ -1,9 +1,9 @@ export class CssAnimationOptions { /** initial styles for the element */ - fromStyles: StringMap; + fromStyles: {[key: string]: any}; /** destination styles for the element */ - toStyles: StringMap; + toStyles: {[key: string]: any}; /** classes to be added to the element */ classesToAdd: string[] = []; diff --git a/modules/angular2/src/core/change_detection/abstract_change_detector.ts b/modules/angular2/src/core/change_detection/abstract_change_detector.ts index 8935c225c1..2946803f1d 100644 --- a/modules/angular2/src/core/change_detection/abstract_change_detector.ts +++ b/modules/angular2/src/core/change_detection/abstract_change_detector.ts @@ -278,7 +278,7 @@ export class AbstractChangeDetector implements ChangeDetector { this.dispatcher.logBindingUpdate(this._currentBinding(), value); } - addChange(changes: StringMap, oldValue: any, newValue: any): StringMap { + addChange(changes: {[key: string]: any}, oldValue: any, newValue: any): {[key: string]: any} { if (isBlank(changes)) { changes = {}; } diff --git a/modules/angular2/src/core/change_detection/change_detection_util.ts b/modules/angular2/src/core/change_detection/change_detection_util.ts index 61a523bc4a..380b2de6a4 100644 --- a/modules/angular2/src/core/change_detection/change_detection_util.ts +++ b/modules/angular2/src/core/change_detection/change_detection_util.ts @@ -124,7 +124,7 @@ export class ChangeDetectionUtil { static cond(cond, trueVal, falseVal): any { return cond ? trueVal : falseVal; } static mapFn(keys: any[]): any { - function buildMap(values): StringMap { + function buildMap(values): {[k: /*any*/ string]: any} { var res = StringMapWrapper.create(); for (var i = 0; i < keys.length; ++i) { StringMapWrapper.set(res, keys[i], values[i]); diff --git a/modules/angular2/src/core/compiler/directive_metadata.ts b/modules/angular2/src/core/compiler/directive_metadata.ts index 3b2ca76489..fea72ea757 100644 --- a/modules/angular2/src/core/compiler/directive_metadata.ts +++ b/modules/angular2/src/core/compiler/directive_metadata.ts @@ -34,12 +34,12 @@ export class CompileTypeMetadata { this.isHost = normalizeBool(isHost); } - static fromJson(data: StringMap): CompileTypeMetadata { + static fromJson(data: {[key: string]: any}): CompileTypeMetadata { return new CompileTypeMetadata( {name: data['name'], moduleUrl: data['moduleUrl'], isHost: data['isHost']}); } - toJson(): StringMap { + toJson(): {[key: string]: any} { return { // Note: Runtime type can't be serialized... 'name': this.name, @@ -72,7 +72,7 @@ export class CompileTemplateMetadata { this.ngContentSelectors = isPresent(ngContentSelectors) ? ngContentSelectors : []; } - static fromJson(data: StringMap): CompileTemplateMetadata { + static fromJson(data: {[key: string]: any}): CompileTemplateMetadata { return new CompileTemplateMetadata({ encapsulation: isPresent(data['encapsulation']) ? VIEW_ENCAPSULATION_VALUES[data['encapsulation']] : @@ -85,7 +85,7 @@ export class CompileTemplateMetadata { }); } - toJson(): StringMap { + toJson(): {[key: string]: any} { return { 'encapsulation': isPresent(this.encapsulation) ? serializeEnum(this.encapsulation) : this.encapsulation, @@ -109,7 +109,7 @@ export class CompileDirectiveMetadata { changeDetection?: ChangeDetectionStrategy, inputs?: string[], outputs?: string[], - host?: StringMap, + host?: {[key: string]: string}, lifecycleHooks?: LifecycleHooks[], template?: CompileTemplateMetadata } = {}): CompileDirectiveMetadata { @@ -169,11 +169,11 @@ export class CompileDirectiveMetadata { selector: string; exportAs: string; changeDetection: ChangeDetectionStrategy; - inputs: StringMap; - outputs: StringMap; - hostListeners: StringMap; - hostProperties: StringMap; - hostAttributes: StringMap; + inputs: {[key: string]: string}; + outputs: {[key: string]: string}; + hostListeners: {[key: string]: string}; + hostProperties: {[key: string]: string}; + hostAttributes: {[key: string]: string}; lifecycleHooks: LifecycleHooks[]; template: CompileTemplateMetadata; constructor({type, isComponent, dynamicLoadable, selector, exportAs, changeDetection, inputs, @@ -184,11 +184,11 @@ export class CompileDirectiveMetadata { selector?: string, exportAs?: string, changeDetection?: ChangeDetectionStrategy, - inputs?: StringMap, - outputs?: StringMap, - hostListeners?: StringMap, - hostProperties?: StringMap, - hostAttributes?: StringMap, + inputs?: {[key: string]: string}, + outputs?: {[key: string]: string}, + hostListeners?: {[key: string]: string}, + hostProperties?: {[key: string]: string}, + hostAttributes?: {[key: string]: string}, lifecycleHooks?: LifecycleHooks[], template?: CompileTemplateMetadata } = {}) { @@ -207,7 +207,7 @@ export class CompileDirectiveMetadata { this.template = template; } - static fromJson(data: StringMap): CompileDirectiveMetadata { + static fromJson(data: {[key: string]: any}): CompileDirectiveMetadata { return new CompileDirectiveMetadata({ isComponent: data['isComponent'], dynamicLoadable: data['dynamicLoadable'], @@ -229,7 +229,7 @@ export class CompileDirectiveMetadata { }); } - toJson(): StringMap { + toJson(): {[key: string]: any} { return { 'isComponent': this.isComponent, 'dynamicLoadable': this.dynamicLoadable, diff --git a/modules/angular2/src/core/compiler/template_parser.ts b/modules/angular2/src/core/compiler/template_parser.ts index bb9d726676..e760b213f4 100644 --- a/modules/angular2/src/core/compiler/template_parser.ts +++ b/modules/angular2/src/core/compiler/template_parser.ts @@ -436,8 +436,8 @@ class TemplateParseVisitor implements HtmlAstVisitor { return directiveAsts; } - private _createDirectiveHostPropertyAsts(elementName: string, - hostProps: StringMap, sourceInfo: string, + private _createDirectiveHostPropertyAsts(elementName: string, hostProps: {[key: string]: string}, + sourceInfo: string, targetPropertyAsts: BoundElementPropertyAst[]) { if (isPresent(hostProps)) { StringMapWrapper.forEach(hostProps, (expression, propName) => { @@ -448,8 +448,8 @@ class TemplateParseVisitor implements HtmlAstVisitor { } } - private _createDirectiveHostEventAsts(hostListeners: StringMap, - sourceInfo: string, targetEventAsts: BoundEventAst[]) { + private _createDirectiveHostEventAsts(hostListeners: {[key: string]: string}, sourceInfo: string, + targetEventAsts: BoundEventAst[]) { if (isPresent(hostListeners)) { StringMapWrapper.forEach(hostListeners, (expression, propName) => { this._parseEvent(propName, expression, sourceInfo, [], targetEventAsts); @@ -457,7 +457,7 @@ class TemplateParseVisitor implements HtmlAstVisitor { } } - private _createDirectivePropertyAsts(directiveProperties: StringMap, + private _createDirectivePropertyAsts(directiveProperties: {[key: string]: string}, boundProps: BoundElementOrDirectiveProperty[], targetBoundDirectiveProps: BoundDirectivePropertyAst[]) { if (isPresent(directiveProperties)) { diff --git a/modules/angular2/src/core/dom/dom_adapter.ts b/modules/angular2/src/core/dom/dom_adapter.ts index 22147ecdda..93cb5d799d 100644 --- a/modules/angular2/src/core/dom/dom_adapter.ts +++ b/modules/angular2/src/core/dom/dom_adapter.ts @@ -27,7 +27,7 @@ export abstract class DomAdapter { * Maps attribute names to their corresponding property names for cases * where attribute name doesn't match property name. */ - attrToPropMap: StringMap; + attrToPropMap: {[key: string]: string}; abstract parse(templateHtml: string); abstract query(selector: string): any; diff --git a/modules/angular2/src/core/dom/parse5_adapter.ts b/modules/angular2/src/core/dom/parse5_adapter.ts index 128e1666c3..b40c6b3c27 100644 --- a/modules/angular2/src/core/dom/parse5_adapter.ts +++ b/modules/angular2/src/core/dom/parse5_adapter.ts @@ -115,9 +115,9 @@ export class Parse5DomAdapter extends DomAdapter { return result; } on(el, evt, listener) { - var listenersMap: StringMap = el._eventListenersMap; + var listenersMap: {[k: /*any*/ string]: any} = el._eventListenersMap; if (isBlank(listenersMap)) { - var listenersMap: StringMap = StringMapWrapper.create(); + var listenersMap: {[k: /*any*/ string]: any} = StringMapWrapper.create(); el._eventListenersMap = listenersMap; } var listeners = StringMapWrapper.get(listenersMap, evt); @@ -492,7 +492,7 @@ export class Parse5DomAdapter extends DomAdapter { var rules = []; for (var i = 0; i < parsedRules.length; i++) { var parsedRule = parsedRules[i]; - var rule: StringMap = StringMapWrapper.create(); + var rule: {[key: string]: any} = StringMapWrapper.create(); StringMapWrapper.set(rule, "cssText", css); StringMapWrapper.set(rule, "style", {content: "", cssText: ""}); if (parsedRule.type == "rule") { diff --git a/modules/angular2/src/core/facade/collection.ts b/modules/angular2/src/core/facade/collection.ts index 03a80bf61e..c97b3d8d59 100644 --- a/modules/angular2/src/core/facade/collection.ts +++ b/modules/angular2/src/core/facade/collection.ts @@ -9,7 +9,6 @@ import { export var Map = global.Map; export var Set = global.Set; -export var StringMap = global.Object; // Safari and Internet Explorer do not support the iterable parameter to the // Map constructor. We work around that by manually adding the items. @@ -79,14 +78,14 @@ var _arrayFromMap: {(m: Map, getValues: boolean): any[]} = (function() export class MapWrapper { static clone(m: Map): Map { return createMapFromMap(m); } - static createFromStringMap(stringMap: StringMap): Map { + static createFromStringMap(stringMap: {[key: string]: T}): Map { var result = new Map(); for (var prop in stringMap) { result.set(prop, stringMap[prop]); } return result; } - static toStringMap(m: Map): StringMap { + static toStringMap(m: Map): {[key: string]: T} { var r = {}; m.forEach((v, k) => r[k] = v); return r; @@ -106,28 +105,28 @@ export class MapWrapper { * Wraps Javascript Objects */ export class StringMapWrapper { - static create(): StringMap { + static create(): {[k: /*any*/ string]: any} { // Note: We are not using Object.create(null) here due to // performance! // http://jsperf.com/ng2-object-create-null return {}; } - static contains(map: StringMap, key: string): boolean { + static contains(map: {[key: string]: any}, key: string): boolean { return map.hasOwnProperty(key); } - static get(map: StringMap, key: string): V { + static get(map: {[key: string]: V}, key: string): V { return map.hasOwnProperty(key) ? map[key] : undefined; } - static set(map: StringMap, key: string, value: V) { map[key] = value; } - static keys(map: StringMap): string[] { return Object.keys(map); } - static isEmpty(map: StringMap): boolean { + static set(map: {[key: string]: V}, key: string, value: V) { map[key] = value; } + static keys(map: {[key: string]: any}): string[] { return Object.keys(map); } + static isEmpty(map: {[key: string]: any}): boolean { for (var prop in map) { return false; } return true; } - static delete (map: StringMap, key: string) { delete map[key]; } - static forEach(map: StringMap, callback: /*(V, K) => void*/ Function) { + static delete (map: {[key: string]: any}, key: string) { delete map[key]; } + static forEach(map: {[key: string]: V}, callback: /*(V, K) => void*/ Function) { for (var prop in map) { if (map.hasOwnProperty(prop)) { callback(map[prop], prop); @@ -135,7 +134,7 @@ export class StringMapWrapper { } } - static merge(m1: StringMap, m2: StringMap): StringMap { + static merge(m1: {[key: string]: V}, m2: {[key: string]: V}): {[key: string]: V} { var m = {}; for (var attr in m1) { @@ -153,7 +152,7 @@ export class StringMapWrapper { return m; } - static equals(m1: StringMap, m2: StringMap): boolean { + static equals(m1: {[key: string]: V}, m2: {[key: string]: V}): boolean { var k1 = Object.keys(m1); var k2 = Object.keys(m2); if (k1.length != k2.length) { diff --git a/modules/angular2/src/core/forms/directives/abstract_control_directive.ts b/modules/angular2/src/core/forms/directives/abstract_control_directive.ts index 9a881f10d4..ac836dec0d 100644 --- a/modules/angular2/src/core/forms/directives/abstract_control_directive.ts +++ b/modules/angular2/src/core/forms/directives/abstract_control_directive.ts @@ -8,7 +8,7 @@ export class AbstractControlDirective { get valid(): boolean { return isPresent(this.control) ? this.control.valid : null; } - get errors(): StringMap { + get errors(): {[key: string]: any} { return isPresent(this.control) ? this.control.errors : null; } @@ -19,4 +19,4 @@ export class AbstractControlDirective { get touched(): boolean { return isPresent(this.control) ? this.control.touched : null; } get untouched(): boolean { return isPresent(this.control) ? this.control.untouched : null; } -} \ No newline at end of file +} diff --git a/modules/angular2/src/core/forms/directives/ng_control_name.ts b/modules/angular2/src/core/forms/directives/ng_control_name.ts index a006a5d6ed..b35d20bdc3 100644 --- a/modules/angular2/src/core/forms/directives/ng_control_name.ts +++ b/modules/angular2/src/core/forms/directives/ng_control_name.ts @@ -1,6 +1,5 @@ import {CONST_EXPR} from 'angular2/src/core/facade/lang'; import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; -import {StringMap} from 'angular2/src/core/facade/collection'; import {OnChanges, OnDestroy} from 'angular2/lifecycle_hooks'; import {SimpleChange} from 'angular2/src/core/change_detection'; import {Query, Directive} from 'angular2/src/core/metadata'; @@ -97,7 +96,7 @@ export class NgControlName extends NgControl implements OnChanges, this.valueAccessor = selectValueAccessor(this, valueAccessors); } - onChanges(changes: StringMap) { + onChanges(changes: {[key: string]: SimpleChange}) { if (!this._added) { this.formDirective.addControl(this); this._added = true; diff --git a/modules/angular2/src/core/forms/directives/ng_form.ts b/modules/angular2/src/core/forms/directives/ng_form.ts index 77bc3681d3..8113f078d1 100644 --- a/modules/angular2/src/core/forms/directives/ng_form.ts +++ b/modules/angular2/src/core/forms/directives/ng_form.ts @@ -98,7 +98,7 @@ export class NgForm extends ControlContainer implements Form { get path(): string[] { return []; } - get controls(): StringMap { return this.form.controls; } + get controls(): {[key: string]: AbstractControl} { return this.form.controls; } addControl(dir: NgControl): void { this._later(_ => { diff --git a/modules/angular2/src/core/forms/directives/ng_form_control.ts b/modules/angular2/src/core/forms/directives/ng_form_control.ts index 9c6482bf52..f6b01d88cd 100644 --- a/modules/angular2/src/core/forms/directives/ng_form_control.ts +++ b/modules/angular2/src/core/forms/directives/ng_form_control.ts @@ -84,7 +84,7 @@ export class NgFormControl extends NgControl implements OnChanges { this.valueAccessor = selectValueAccessor(this, valueAccessors); } - onChanges(changes: StringMap): void { + onChanges(changes: {[key: string]: SimpleChange}): void { if (!this._added) { setUpControl(this.form, this); this.form.updateValidity(); diff --git a/modules/angular2/src/core/forms/directives/ng_model.ts b/modules/angular2/src/core/forms/directives/ng_model.ts index 95ec3e6cf9..c02d41e08e 100644 --- a/modules/angular2/src/core/forms/directives/ng_model.ts +++ b/modules/angular2/src/core/forms/directives/ng_model.ts @@ -55,7 +55,7 @@ export class NgModel extends NgControl implements OnChanges { this.valueAccessor = selectValueAccessor(this, valueAccessors); } - onChanges(changes: StringMap) { + onChanges(changes: {[key: string]: SimpleChange}) { if (!this._added) { setUpControl(this._control, this); this._control.updateValidity(); diff --git a/modules/angular2/src/core/forms/directives/shared.ts b/modules/angular2/src/core/forms/directives/shared.ts index 5a6b5f2548..8c28c5a060 100644 --- a/modules/angular2/src/core/forms/directives/shared.ts +++ b/modules/angular2/src/core/forms/directives/shared.ts @@ -51,7 +51,7 @@ export function setProperty(renderer: Renderer, elementRef: ElementRef, propName renderer.setElementProperty(elementRef, propName, propValue); } -export function isPropertyUpdated(changes: StringMap, viewModel: any): boolean { +export function isPropertyUpdated(changes: {[key: string]: any}, viewModel: any): boolean { if (!StringMapWrapper.contains(changes, "model")) return false; var change = changes["model"]; diff --git a/modules/angular2/src/core/forms/form_builder.ts b/modules/angular2/src/core/forms/form_builder.ts index 9c8ee9c47d..c83a63c68f 100644 --- a/modules/angular2/src/core/forms/form_builder.ts +++ b/modules/angular2/src/core/forms/form_builder.ts @@ -66,8 +66,8 @@ import * as modelModule from './model'; */ @Injectable() export class FormBuilder { - group(controlsConfig: StringMap, - extra: StringMap = null): modelModule.ControlGroup { + group(controlsConfig: {[key: string]: any}, + extra: {[key: string]: any} = null): modelModule.ControlGroup { var controls = this._reduceControls(controlsConfig); var optionals = isPresent(extra) ? StringMapWrapper.get(extra, "optionals") : null; var validator = isPresent(extra) ? StringMapWrapper.get(extra, "validator") : null; @@ -96,7 +96,7 @@ export class FormBuilder { } } - _reduceControls(controlsConfig: any): StringMap { + _reduceControls(controlsConfig: any): {[key: string]: modelModule.AbstractControl} { var controls = {}; StringMapWrapper.forEach(controlsConfig, (controlConfig, controlName) => { controls[controlName] = this._createControl(controlConfig); diff --git a/modules/angular2/src/core/forms/model.ts b/modules/angular2/src/core/forms/model.ts index 69c4af0e6e..9a9c8d3afa 100644 --- a/modules/angular2/src/core/forms/model.ts +++ b/modules/angular2/src/core/forms/model.ts @@ -1,6 +1,6 @@ import {StringWrapper, isPresent, isBlank, normalizeBool} from 'angular2/src/core/facade/lang'; import {Observable, EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; -import {StringMap, StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; +import {StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {Validators} from './validators'; /** @@ -43,7 +43,7 @@ function _find(control: AbstractControl, path: Array| string) { export class AbstractControl { _value: any; _status: string; - _errors: StringMap; + _errors: {[key: string]: any}; _pristine: boolean = true; _touched: boolean = false; _parent: ControlGroup | ControlArray; @@ -58,7 +58,7 @@ export class AbstractControl { get valid(): boolean { return this._status === VALID; } - get errors(): StringMap { return this._errors; } + get errors(): {[key: string]: any} { return this._errors; } get pristine(): boolean { return this._pristine; } @@ -199,11 +199,10 @@ export class Control extends AbstractControl { * ### Example ([live demo](http://plnkr.co/edit/23DESOpbNnBpBHZt1BR4?p=preview)) */ export class ControlGroup extends AbstractControl { - private _optionals: StringMap; + private _optionals: {[key: string]: boolean}; - constructor(public controls: StringMap, - optionals: StringMap = null, - validator: Function = Validators.group) { + constructor(public controls: {[key: string]: AbstractControl}, + optionals: {[key: string]: boolean} = null, validator: Function = Validators.group) { super(validator); this._optionals = isPresent(optionals) ? optionals : {}; this._valueChanges = new EventEmitter(); diff --git a/modules/angular2/src/core/forms/validators.ts b/modules/angular2/src/core/forms/validators.ts index aa97caa02e..56ef933ad1 100644 --- a/modules/angular2/src/core/forms/validators.ts +++ b/modules/angular2/src/core/forms/validators.ts @@ -17,11 +17,11 @@ export const NG_VALIDATORS: OpaqueToken = CONST_EXPR(new OpaqueToken("NgValidato * ``` */ export class Validators { - static required(control: modelModule.Control): StringMap { + static required(control: modelModule.Control): {[key: string]: boolean} { return isBlank(control.value) || control.value == "" ? {"required": true} : null; } - static nullValidator(c: any): StringMap { return null; } + static nullValidator(c: any): {[key: string]: boolean} { return null; } static compose(validators: Function[]): Function { if (isBlank(validators)) return Validators.nullValidator; @@ -35,7 +35,7 @@ export class Validators { }; } - static group(group: modelModule.ControlGroup): StringMap { + static group(group: modelModule.ControlGroup): {[key: string]: boolean} { var res = {}; StringMapWrapper.forEach(group.controls, (control, name) => { if (group.contains(name) && isPresent(control.errors)) { @@ -45,7 +45,7 @@ export class Validators { return StringMapWrapper.isEmpty(res) ? null : res; } - static array(array: modelModule.ControlArray): StringMap { + static array(array: modelModule.ControlArray): {[key: string]: boolean} { var res = {}; array.controls.forEach((control) => { if (isPresent(control.errors)) { @@ -55,7 +55,7 @@ export class Validators { return StringMapWrapper.isEmpty(res) ? null : res; } - static _mergeErrors(control: modelModule.AbstractControl, res: StringMap): void { + static _mergeErrors(control: modelModule.AbstractControl, res: {[key: string]: any[]}): void { StringMapWrapper.forEach(control.errors, (value, error) => { if (!StringMapWrapper.contains(res, error)) { res[error] = []; diff --git a/modules/angular2/src/core/linker/directive_resolver.ts b/modules/angular2/src/core/linker/directive_resolver.ts index 10897a8539..81f884c20c 100644 --- a/modules/angular2/src/core/linker/directive_resolver.ts +++ b/modules/angular2/src/core/linker/directive_resolver.ts @@ -1,7 +1,7 @@ import {resolveForwardRef, Injectable} from 'angular2/src/core/di'; import {Type, isPresent, isBlank, stringify} from 'angular2/src/core/facade/lang'; import {BaseException} from 'angular2/src/core/facade/exceptions'; -import {ListWrapper, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; +import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import { DirectiveMetadata, ComponentMetadata, @@ -43,8 +43,7 @@ export class DirectiveResolver { } private _mergeWithPropertyMetadata(dm: DirectiveMetadata, - propertyMetadata: - StringMap): DirectiveMetadata { + propertyMetadata: {[key: string]: any[]}): DirectiveMetadata { var inputs = []; var outputs = []; var host = {}; @@ -102,8 +101,7 @@ export class DirectiveResolver { } private _merge(dm: DirectiveMetadata, inputs: string[], outputs: string[], - host: StringMap, - queries: StringMap): DirectiveMetadata { + host: {[key: string]: string}, queries: {[key: string]: any}): DirectiveMetadata { var mergedInputs = isPresent(dm.inputs) ? ListWrapper.concat(dm.inputs, inputs) : inputs; var mergedOutputs = isPresent(dm.outputs) ? ListWrapper.concat(dm.outputs, outputs) : outputs; var mergedHost = isPresent(dm.host) ? StringMapWrapper.merge(dm.host, host) : host; diff --git a/modules/angular2/src/core/linker/interfaces.ts b/modules/angular2/src/core/linker/interfaces.ts index f94f3044f1..5051d55aa3 100644 --- a/modules/angular2/src/core/linker/interfaces.ts +++ b/modules/angular2/src/core/linker/interfaces.ts @@ -1,4 +1,4 @@ -import {StringMap, MapWrapper} from 'angular2/src/core/facade/collection'; +import {MapWrapper} from 'angular2/src/core/facade/collection'; import {SimpleChange} from 'angular2/src/core/change_detection/change_detection_util'; /** @@ -77,7 +77,7 @@ export var LIFECYCLE_HOOKS_VALUES = [ * bootstrap(App).catch(err => console.error(err)); * ``` */ -export interface OnChanges { onChanges(changes: StringMap); } +export interface OnChanges { onChanges(changes: {[key: string]: SimpleChange}); } /** * Implement this interface to execute custom initialization logic after your directive's diff --git a/modules/angular2/src/core/linker/view.ts b/modules/angular2/src/core/linker/view.ts index 5fcff4a4e8..d61018198e 100644 --- a/modules/angular2/src/core/linker/view.ts +++ b/modules/angular2/src/core/linker/view.ts @@ -3,7 +3,6 @@ import { MapWrapper, Map, StringMapWrapper, - StringMap } from 'angular2/src/core/facade/collection'; import { AST, @@ -263,7 +262,7 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher { get ownBindersCount(): number { return this.proto.elementBinders.length; } } -function _localsToStringMap(locals: Locals): StringMap { +function _localsToStringMap(locals: Locals): {[key: string]: any} { var res = {}; var c = locals; while (isPresent(c)) { @@ -339,4 +338,4 @@ export class AppProtoView { } isInitialized(): boolean { return isPresent(this.elementBinders); } -} \ No newline at end of file +} diff --git a/modules/angular2/src/core/metadata.ts b/modules/angular2/src/core/metadata.ts index 4b45e02969..c198d6c701 100644 --- a/modules/angular2/src/core/metadata.ts +++ b/modules/angular2/src/core/metadata.ts @@ -151,11 +151,11 @@ export interface DirectiveFactory { outputs?: string[], properties?: string[], events?: string[], - host?: StringMap, + host?: {[key: string]: string}, bindings?: any[], exportAs?: string, moduleId?: string, - queries?: StringMap + queries?: {[key: string]: any} }): DirectiveDecorator; new (obj: { selector?: string, @@ -163,11 +163,11 @@ export interface DirectiveFactory { outputs?: string[], properties?: string[], events?: string[], - host?: StringMap, + host?: {[key: string]: string}, bindings?: any[], exportAs?: string, moduleId?: string, - queries?: StringMap + queries?: {[key: string]: any} }): DirectiveMetadata; } @@ -221,11 +221,11 @@ export interface ComponentFactory { outputs?: string[], properties?: string[], events?: string[], - host?: StringMap, + host?: {[key: string]: string}, bindings?: any[], exportAs?: string, moduleId?: string, - queries?: StringMap, + queries?: {[key: string]: any}, viewBindings?: any[], changeDetection?: ChangeDetectionStrategy, }): ComponentDecorator; @@ -235,11 +235,11 @@ export interface ComponentFactory { outputs?: string[], properties?: string[], events?: string[], - host?: StringMap, + host?: {[key: string]: string}, bindings?: any[], exportAs?: string, moduleId?: string, - queries?: StringMap, + queries?: {[key: string]: any}, viewBindings?: any[], changeDetection?: ChangeDetectionStrategy, }): ComponentMetadata; diff --git a/modules/angular2/src/core/metadata/directives.ts b/modules/angular2/src/core/metadata/directives.ts index c693f93a5f..4447e914f0 100644 --- a/modules/angular2/src/core/metadata/directives.ts +++ b/modules/angular2/src/core/metadata/directives.ts @@ -632,7 +632,7 @@ export class DirectiveMetadata extends InjectableMetadata { * } * ``` */ - host: StringMap; + host: {[key: string]: string}; /** * Defines the set of injectable objects that are visible to a Directive and its light DOM @@ -748,7 +748,7 @@ export class DirectiveMetadata extends InjectableMetadata { * } * ``` */ - queries: StringMap; + queries: {[key: string]: any}; constructor({selector, inputs, outputs, properties, events, host, bindings, exportAs, moduleId, queries}: { @@ -757,11 +757,11 @@ export class DirectiveMetadata extends InjectableMetadata { outputs?: string[], properties?: string[], events?: string[], - host?: StringMap, + host?: {[key: string]: string}, bindings?: any[], exportAs?: string, moduleId?: string, - queries?: StringMap + queries?: {[key: string]: any} } = {}) { super(); this.selector = selector; @@ -883,12 +883,12 @@ export class ComponentMetadata extends DirectiveMetadata { outputs?: string[], properties?: string[], events?: string[], - host?: StringMap, + host?: {[key: string]: string}, bindings?: any[], exportAs?: string, moduleId?: string, viewBindings?: any[], - queries?: StringMap, + queries?: {[key: string]: any}, changeDetection?: ChangeDetectionStrategy, } = {}) { super({ diff --git a/modules/angular2/src/core/pipes/pipes.ts b/modules/angular2/src/core/pipes/pipes.ts index 585d5da72f..3a17607c14 100644 --- a/modules/angular2/src/core/pipes/pipes.ts +++ b/modules/angular2/src/core/pipes/pipes.ts @@ -23,7 +23,7 @@ export class ProtoPipes { /** * Map of {@link PipeMetadata} names to {@link PipeMetadata} implementations. */ - public config: StringMap) { + public config: {[key: string]: PipeBinding}) { this.config = config; } @@ -37,7 +37,7 @@ export class ProtoPipes { export class Pipes implements cd.Pipes { - _config: StringMap = {}; + _config: {[key: string]: cd.SelectedPipe} = {}; constructor(public proto: ProtoPipes, public injector: Injector) {} diff --git a/modules/angular2/src/core/reflection/platform_reflection_capabilities.ts b/modules/angular2/src/core/reflection/platform_reflection_capabilities.ts index 36b196d391..83f87fec84 100644 --- a/modules/angular2/src/core/reflection/platform_reflection_capabilities.ts +++ b/modules/angular2/src/core/reflection/platform_reflection_capabilities.ts @@ -7,7 +7,7 @@ export interface PlatformReflectionCapabilities { interfaces(type: Type): any[]; parameters(type: any): any[][]; annotations(type: any): any[]; - propMetadata(typeOrFunc: any): StringMap; + propMetadata(typeOrFunc: any): {[key: string]: any[]}; getter(name: string): GetterFn; setter(name: string): SetterFn; method(name: string): MethodFn; diff --git a/modules/angular2/src/core/reflection/reflection_capabilities.ts b/modules/angular2/src/core/reflection/reflection_capabilities.ts index c27dfc94fc..9728f01176 100644 --- a/modules/angular2/src/core/reflection/reflection_capabilities.ts +++ b/modules/angular2/src/core/reflection/reflection_capabilities.ts @@ -134,7 +134,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities { return []; } - propMetadata(typeOrFunc: any): StringMap { + propMetadata(typeOrFunc: any): {[key: string]: any[]} { // Prefer the direct API. if (isPresent((typeOrFunc).propMetadata)) { var propMetadata = (typeOrFunc).propMetadata; diff --git a/modules/angular2/src/core/reflection/reflector.ts b/modules/angular2/src/core/reflection/reflector.ts index 955e53d98a..b961479b9e 100644 --- a/modules/angular2/src/core/reflection/reflector.ts +++ b/modules/angular2/src/core/reflection/reflector.ts @@ -6,7 +6,6 @@ import { MapWrapper, Set, SetWrapper, - StringMap, StringMapWrapper } from 'angular2/src/core/facade/collection'; import {SetterFn, GetterFn, MethodFn} from './types'; @@ -16,7 +15,7 @@ export {PlatformReflectionCapabilities} from './platform_reflection_capabilities export class ReflectionInfo { constructor(public annotations?: any[], public parameters?: any[][], public factory?: Function, - public interfaces?: any[], public propMetadata?: StringMap) {} + public interfaces?: any[], public propMetadata?: {[key: string]: any[]}) {} } export class Reflector { @@ -61,17 +60,11 @@ export class Reflector { this._injectableInfo.set(type, typeInfo); } - registerGetters(getters: StringMap): void { - _mergeMaps(this._getters, getters); - } + registerGetters(getters: {[key: string]: GetterFn}): void { _mergeMaps(this._getters, getters); } - registerSetters(setters: StringMap): void { - _mergeMaps(this._setters, setters); - } + registerSetters(setters: {[key: string]: SetterFn}): void { _mergeMaps(this._setters, setters); } - registerMethods(methods: StringMap): void { - _mergeMaps(this._methods, methods); - } + registerMethods(methods: {[key: string]: MethodFn}): void { _mergeMaps(this._methods, methods); } factory(type: Type): Function { if (this._containsReflectionInfo(type)) { @@ -100,7 +93,7 @@ export class Reflector { } } - propMetadata(typeOrFunc: /*Type*/ any): StringMap { + propMetadata(typeOrFunc: /*Type*/ any): {[key: string]: any[]} { if (this._injectableInfo.has(typeOrFunc)) { var res = this._getReflectionInfo(typeOrFunc).propMetadata; return isPresent(res) ? res : {}; @@ -154,6 +147,6 @@ export class Reflector { importUri(type: Type): string { return this.reflectionCapabilities.importUri(type); } } -function _mergeMaps(target: Map, config: StringMap): void { +function _mergeMaps(target: Map, config: {[key: string]: Function}): void { StringMapWrapper.forEach(config, (v, k) => target.set(k, v)); } diff --git a/modules/angular2/src/core/render/dom/events/key_events.ts b/modules/angular2/src/core/render/dom/events/key_events.ts index c855b12945..4c3b55b8b1 100644 --- a/modules/angular2/src/core/render/dom/events/key_events.ts +++ b/modules/angular2/src/core/render/dom/events/key_events.ts @@ -12,7 +12,7 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {Injectable} from 'angular2/src/core/di'; var modifierKeys = ['alt', 'control', 'meta', 'shift']; -var modifierKeyGetters: StringMap = { +var modifierKeyGetters: {[key: string]: Function} = { 'alt': (event) => event.altKey, 'control': (event) => event.ctrlKey, 'meta': (event) => event.metaKey, @@ -38,7 +38,7 @@ export class KeyEventsPlugin extends EventManagerPlugin { }); } - static parseEventName(eventName: string): StringMap { + static parseEventName(eventName: string): {[key: string]: string} { var parts = eventName.toLowerCase().split('.'); var domEventName = ListWrapper.removeAt(parts, 0); diff --git a/modules/angular2/src/http/enums.ts b/modules/angular2/src/http/enums.ts index 322131e63c..5bb048272a 100644 --- a/modules/angular2/src/http/enums.ts +++ b/modules/angular2/src/http/enums.ts @@ -1,4 +1,4 @@ -import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; +import {StringMapWrapper} from 'angular2/src/core/facade/collection'; /** * Supported http methods. diff --git a/modules/angular2/src/http/headers.ts b/modules/angular2/src/http/headers.ts index 30ec9398f5..77d235657c 100644 --- a/modules/angular2/src/http/headers.ts +++ b/modules/angular2/src/http/headers.ts @@ -5,7 +5,6 @@ import { Map, MapWrapper, ListWrapper, - StringMap } from 'angular2/src/core/facade/collection'; /** @@ -36,7 +35,7 @@ import { */ export class Headers { _headersMap: Map; - constructor(headers?: Headers | StringMap) { + constructor(headers?: Headers | {[key: string]: any}) { if (isBlank(headers)) { this._headersMap = new Map(); return; @@ -44,7 +43,7 @@ export class Headers { if (headers instanceof Headers) { this._headersMap = (headers)._headersMap; - } else if (headers instanceof StringMap) { + } else /*if (headers instanceof StringMap)*/ { this._headersMap = MapWrapper.createFromStringMap(headers); MapWrapper.forEach(this._headersMap, (v, k) => { if (!isListLikeIterable(v)) { diff --git a/modules/angular2/src/router/instruction.ts b/modules/angular2/src/router/instruction.ts index 9f96420bb4..3df598ca2f 100644 --- a/modules/angular2/src/router/instruction.ts +++ b/modules/angular2/src/router/instruction.ts @@ -1,10 +1,4 @@ -import { - Map, - MapWrapper, - StringMap, - StringMapWrapper, - ListWrapper -} from 'angular2/src/core/facade/collection'; +import {Map, MapWrapper, StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {isPresent, isBlank, normalizeBlank, Type} from 'angular2/src/core/facade/lang'; import {Promise} from 'angular2/src/core/facade/async'; @@ -43,7 +37,7 @@ import {Url} from './url_parser'; * ``` */ export class RouteParams { - constructor(public params: StringMap) {} + constructor(public params: {[key: string]: string}) {} get(param: string): string { return normalizeBlank(StringMapWrapper.get(this.params, param)); } } @@ -78,7 +72,7 @@ export class RouteParams { */ export class Instruction { constructor(public component: ComponentInstruction, public child: Instruction, - public auxInstruction: StringMap) {} + public auxInstruction: {[key: string]: Instruction}) {} /** * Returns a new instruction that shares the state of the existing instruction, but with @@ -153,7 +147,7 @@ export class ComponentInstruction { * @private */ constructor(public urlPath: string, public urlParams: string[], - private _recognizer: PathRecognizer, public params: StringMap = null) {} + private _recognizer: PathRecognizer, public params: {[key: string]: any} = null) {} /** * Returns the component type of the represented route, or `null` if this instruction diff --git a/modules/angular2/src/router/path_recognizer.ts b/modules/angular2/src/router/path_recognizer.ts index 860b28bbfa..10dd66429d 100644 --- a/modules/angular2/src/router/path_recognizer.ts +++ b/modules/angular2/src/router/path_recognizer.ts @@ -8,23 +8,17 @@ import { } from 'angular2/src/core/facade/lang'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; -import { - Map, - MapWrapper, - StringMap, - StringMapWrapper, - ListWrapper -} from 'angular2/src/core/facade/collection'; +import {Map, MapWrapper, StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {RouteHandler} from './route_handler'; import {Url, RootUrl, serializeParams} from './url_parser'; import {ComponentInstruction} from './instruction'; class TouchMap { - map: StringMap = {}; - keys: StringMap = {}; + map: {[key: string]: string} = {}; + keys: {[key: string]: boolean} = {}; - constructor(map: StringMap) { + constructor(map: {[key: string]: any}) { if (isPresent(map)) { StringMapWrapper.forEach(map, (value, key) => { this.map[key] = isPresent(value) ? value.toString() : null; @@ -38,8 +32,8 @@ class TouchMap { return this.map[key]; } - getUnused(): StringMap { - var unused: StringMap = StringMapWrapper.create(); + getUnused(): {[key: string]: any} { + var unused: {[key: string]: any} = StringMapWrapper.create(); var keys = StringMapWrapper.keys(this.keys); ListWrapper.forEach(keys, (key) => { unused[key] = StringMapWrapper.get(this.map, key); }); return unused; @@ -96,7 +90,7 @@ class StarSegment implements Segment { var paramMatcher = /^:([^\/]+)$/g; var wildcardMatcher = /^\*([^\/]+)$/g; -function parsePathString(route: string): StringMap { +function parsePathString(route: string): {[key: string]: any} { // normalize route as not starting with a "/". Recognition will // also normalize. if (StringWrapper.startsWith(route, "/")) { @@ -278,7 +272,7 @@ export class PathRecognizer { } - generate(params: StringMap): ComponentInstruction { + generate(params: {[key: string]: any}): ComponentInstruction { var paramTokens = new TouchMap(params); var path = []; @@ -298,7 +292,7 @@ export class PathRecognizer { } private _getInstruction(urlPath: string, urlParams: string[], _recognizer: PathRecognizer, - params: StringMap): ComponentInstruction { + params: {[key: string]: any}): ComponentInstruction { var hashKey = urlPath + '?' + urlParams.join('?'); if (this._cache.has(hashKey)) { return this._cache.get(hashKey); diff --git a/modules/angular2/src/router/route_recognizer.ts b/modules/angular2/src/router/route_recognizer.ts index 8cf74ea038..7d82b8f28b 100644 --- a/modules/angular2/src/router/route_recognizer.ts +++ b/modules/angular2/src/router/route_recognizer.ts @@ -9,13 +9,7 @@ import { Type } from 'angular2/src/core/facade/lang'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; -import { - Map, - MapWrapper, - ListWrapper, - StringMap, - StringMapWrapper -} from 'angular2/src/core/facade/collection'; +import {Map, MapWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {PathRecognizer, PathMatch} from './path_recognizer'; import {Route, AsyncRoute, AuxRoute, Redirect, RouteDefinition} from './route_config_impl'; diff --git a/modules/angular2/src/router/route_registry.ts b/modules/angular2/src/router/route_registry.ts index 85235aca48..537af42175 100644 --- a/modules/angular2/src/router/route_registry.ts +++ b/modules/angular2/src/router/route_registry.ts @@ -1,13 +1,7 @@ import {PathMatch} from './path_recognizer'; import {RouteRecognizer} from './route_recognizer'; import {Instruction, ComponentInstruction, PrimaryInstruction} from './instruction'; -import { - ListWrapper, - Map, - MapWrapper, - StringMap, - StringMapWrapper -} from 'angular2/src/core/facade/collection'; +import {ListWrapper, Map, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; import { isPresent, diff --git a/modules/angular2/src/router/router_link.ts b/modules/angular2/src/router/router_link.ts index 3d9344f35b..a0a19ae290 100644 --- a/modules/angular2/src/router/router_link.ts +++ b/modules/angular2/src/router/router_link.ts @@ -1,5 +1,5 @@ import {Directive} from '../core/metadata'; -import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; +import {StringMapWrapper} from 'angular2/src/core/facade/collection'; import {Router} from './router'; import {Location} from './location'; diff --git a/modules/angular2/src/router/url_parser.ts b/modules/angular2/src/router/url_parser.ts index a09f38ecdf..5ee22415a2 100644 --- a/modules/angular2/src/router/url_parser.ts +++ b/modules/angular2/src/router/url_parser.ts @@ -1,4 +1,4 @@ -import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; +import {StringMapWrapper} from 'angular2/src/core/facade/collection'; import { isPresent, isBlank, @@ -14,7 +14,7 @@ import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptio export class Url { constructor(public path: string, public child: Url = null, public auxiliary: Url[] = CONST_EXPR([]), - public params: StringMap = null) {} + public params: {[key: string]: any} = null) {} toString(): string { return this.path + this._matrixParamsToString() + this._auxToString() + this._childString(); @@ -41,7 +41,7 @@ export class Url { export class RootUrl extends Url { constructor(path: string, child: Url = null, auxiliary: Url[] = CONST_EXPR([]), - params: StringMap = null) { + params: {[key: string]: any} = null) { super(path, child, auxiliary, params); } @@ -149,7 +149,7 @@ export class UrlParser { return new Url(path, child, aux, matrixParams); } - parseQueryParams(): StringMap { + parseQueryParams(): {[key: string]: any} { var params = {}; this.capture('?'); this.parseParam(params); @@ -160,7 +160,7 @@ export class UrlParser { return params; } - parseMatrixParams(): StringMap { + parseMatrixParams(): {[key: string]: any} { var params = {}; while (this._remaining.length > 0 && this.peekStartsWith(';')) { this.capture(';'); @@ -169,7 +169,7 @@ export class UrlParser { return params; } - parseParam(params: StringMap): void { + parseParam(params: {[key: string]: any}): void { var key = matchUrlSegment(this._remaining); if (isBlank(key)) { return; @@ -206,7 +206,7 @@ export class UrlParser { export var parser = new UrlParser(); -export function serializeParams(paramMap: StringMap): string[] { +export function serializeParams(paramMap: {[key: string]: any}): string[] { var params = []; if (isPresent(paramMap)) { StringMapWrapper.forEach(paramMap, (value, key) => { diff --git a/modules/angular2/src/web_workers/shared/client_message_broker.ts b/modules/angular2/src/web_workers/shared/client_message_broker.ts index 2b47fd1265..87a59035b1 100644 --- a/modules/angular2/src/web_workers/shared/client_message_broker.ts +++ b/modules/angular2/src/web_workers/shared/client_message_broker.ts @@ -41,7 +41,7 @@ export class ClientMessageBroker { this._sink = messageBus.to(channel); var source = messageBus.from(channel); ObservableWrapper.subscribe(source, - (message: StringMap) => this._handleMessage(message)); + (message: {[key: string]: any}) => this._handleMessage(message)); } private _generateMessageId(name: string): string { @@ -99,7 +99,7 @@ export class ClientMessageBroker { return promise; } - private _handleMessage(message: StringMap): void { + private _handleMessage(message: {[key: string]: any}): void { var data = new MessageData(message); // TODO(jteplitz602): replace these strings with messaging constants #3685 if (StringWrapper.equals(data.type, "result") || StringWrapper.equals(data.type, "error")) { @@ -121,7 +121,7 @@ class MessageData { value: any; id: string; - constructor(data: StringMap) { + constructor(data: {[key: string]: any}) { this.type = StringMapWrapper.get(data, "type"); this.id = this._getValueIfPresent(data, "id"); this.value = this._getValueIfPresent(data, "value"); @@ -130,7 +130,7 @@ class MessageData { /** * Returns the value from the StringMap if present. Otherwise returns null */ - _getValueIfPresent(data: StringMap, key: string) { + _getValueIfPresent(data: {[key: string]: any}, key: string) { if (StringMapWrapper.contains(data, key)) { return StringMapWrapper.get(data, key); } else { diff --git a/modules/angular2/src/web_workers/shared/post_message_bus.ts b/modules/angular2/src/web_workers/shared/post_message_bus.ts index 63abc1b594..1c2c404b70 100644 --- a/modules/angular2/src/web_workers/shared/post_message_bus.ts +++ b/modules/angular2/src/web_workers/shared/post_message_bus.ts @@ -5,7 +5,7 @@ import { } from "angular2/src/web_workers/shared/message_bus"; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; import {EventEmitter} from 'angular2/src/core/facade/async'; -import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; +import {StringMapWrapper} from 'angular2/src/core/facade/collection'; import {Injectable} from "angular2/src/core/di"; import {NgZone} from 'angular2/src/core/zone/ng_zone'; @@ -34,7 +34,7 @@ export class PostMessageBus implements MessageBus { export class PostMessageBusSink implements MessageBusSink { private _zone: NgZone; - private _channels: StringMap = StringMapWrapper.create(); + private _channels: {[key: string]: _Channel} = StringMapWrapper.create(); private _messageBuffer: Array = []; constructor(private _postMessageTarget: PostMessageTarget) {} @@ -83,7 +83,7 @@ export class PostMessageBusSink implements MessageBusSink { export class PostMessageBusSource implements MessageBusSource { private _zone: NgZone; - private _channels: StringMap = StringMapWrapper.create(); + private _channels: {[key: string]: _Channel} = StringMapWrapper.create(); constructor(eventTarget?: EventTarget) { if (eventTarget) { 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 2aefdaa769..ee04320281 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 @@ -112,7 +112,7 @@ export class RenderViewWithFragmentsStore { } } - serializeViewWithFragments(view: RenderViewWithFragments): StringMap { + serializeViewWithFragments(view: RenderViewWithFragments): {[key: string]: any} { if (view == null) { return null; } @@ -130,7 +130,7 @@ export class RenderViewWithFragmentsStore { } } - deserializeViewWithFragments(obj: StringMap): RenderViewWithFragments { + deserializeViewWithFragments(obj: {[key: string]: any}): RenderViewWithFragments { if (obj == null) { return null; } diff --git a/modules/angular2/src/web_workers/shared/serializer.ts b/modules/angular2/src/web_workers/shared/serializer.ts index a827d11b3f..b66a079743 100644 --- a/modules/angular2/src/web_workers/shared/serializer.ts +++ b/modules/angular2/src/web_workers/shared/serializer.ts @@ -7,13 +7,7 @@ import { } from "angular2/src/core/facade/lang"; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; -import { - ListWrapper, - Map, - StringMap, - StringMapWrapper, - MapWrapper -} from "angular2/src/core/facade/collection"; +import {ListWrapper, Map, StringMapWrapper, MapWrapper} from "angular2/src/core/facade/collection"; import { RenderProtoViewRef, RenderViewRef, @@ -144,7 +138,7 @@ export class Serializer { * If the values need to be deserialized pass in their type * and they will be deserialized before being placed in the map */ - objectToMap(obj: StringMap, type?: Type, data?: any): Map { + objectToMap(obj: {[key: string]: any}, type?: Type, data?: any): Map { if (isPresent(type)) { var map = new Map(); StringMapWrapper.forEach(obj, @@ -157,14 +151,14 @@ export class Serializer { allocateRenderViews(fragmentCount: number) { this._renderViewStore.allocate(fragmentCount); } - private _serializeWorkerElementRef(elementRef: RenderElementRef): StringMap { + private _serializeWorkerElementRef(elementRef: RenderElementRef): {[key: string]: any} { return { 'renderView': this.serialize(elementRef.renderView, RenderViewRef), 'boundElementIndex': elementRef.boundElementIndex }; } - private _deserializeWorkerElementRef(map: StringMap): RenderElementRef { + private _deserializeWorkerElementRef(map: {[key: string]: any}): RenderElementRef { return new WebWorkerElementRef(this.deserialize(map['renderView'], RenderViewRef), map['boundElementIndex']); } @@ -174,7 +168,7 @@ function serializeTemplateCmd(cmd: RenderTemplateCmd): Object { return cmd.visit(RENDER_TEMPLATE_CMD_SERIALIZER, null); } -function deserializeTemplateCmd(data: StringMap): RenderTemplateCmd { +function deserializeTemplateCmd(data: {[key: string]: any}): RenderTemplateCmd { return RENDER_TEMPLATE_CMD_DESERIALIZERS[data['deserializerIndex']](data); } @@ -232,18 +226,18 @@ class RenderTemplateCmdSerializer implements RenderCommandVisitor { var RENDER_TEMPLATE_CMD_SERIALIZER = new RenderTemplateCmdSerializer(); var RENDER_TEMPLATE_CMD_DESERIALIZERS = [ - (data: StringMap) => + (data: {[key: string]: any}) => new WebWorkerTextCmd(data['isBound'], data['ngContentIndex'], data['value']), - (data: StringMap) => new WebWorkerNgContentCmd(data['ngContentIndex']), - (data: StringMap) => + (data: {[key: string]: any}) => new WebWorkerNgContentCmd(data['ngContentIndex']), + (data: {[key: string]: any}) => new WebWorkerBeginElementCmd(data['isBound'], data['ngContentIndex'], data['name'], data['attrNameAndValues'], data['eventTargetAndNames']), - (data: StringMap) => new WebWorkerEndElementCmd(), - (data: StringMap) => new WebWorkerBeginComponentCmd( + (data: {[key: string]: any}) => new WebWorkerEndElementCmd(), + (data: {[key: string]: any}) => new WebWorkerBeginComponentCmd( data['isBound'], data['ngContentIndex'], data['name'], data['attrNameAndValues'], data['eventTargetAndNames'], data['nativeShadow'], data['templateId']), - (data: StringMap) => new WebWorkerEndComponentCmd(), - (data: StringMap) => new WebWorkerEmbeddedTemplateCmd( + (data: {[key: string]: any}) => new WebWorkerEndComponentCmd(), + (data: {[key: string]: any}) => new WebWorkerEmbeddedTemplateCmd( data['isBound'], data['ngContentIndex'], data['name'], data['attrNameAndValues'], data['eventTargetAndNames'], data['isMerged'], (data['children']).map(childData => deserializeTemplateCmd(childData))), diff --git a/modules/angular2/src/web_workers/shared/service_message_broker.ts b/modules/angular2/src/web_workers/shared/service_message_broker.ts index 0a2027172b..9f6e7db564 100644 --- a/modules/angular2/src/web_workers/shared/service_message_broker.ts +++ b/modules/angular2/src/web_workers/shared/service_message_broker.ts @@ -61,7 +61,7 @@ export class ServiceMessageBroker { }); } - private _handleMessage(map: StringMap): void { + private _handleMessage(map: {[key: string]: any}): void { var message = new ReceivedMessage(map); if (this._methods.has(message.method)) { this._methods.get(message.method)(message); @@ -83,7 +83,7 @@ export class ReceivedMessage { id: string; type: string; - constructor(data: StringMap) { + constructor(data: {[key: string]: any}) { this.method = data['method']; this.args = data['args']; this.id = data['id']; diff --git a/modules/angular2/src/web_workers/ui/event_serializer.ts b/modules/angular2/src/web_workers/ui/event_serializer.ts index 13e67362ff..453bd0af1a 100644 --- a/modules/angular2/src/web_workers/ui/event_serializer.ts +++ b/modules/angular2/src/web_workers/ui/event_serializer.ts @@ -1,4 +1,4 @@ -import {StringMap, Set} from 'angular2/src/core/facade/collection'; +import {Set} from 'angular2/src/core/facade/collection'; import {isPresent} from 'angular2/src/core/facade/lang'; const MOUSE_EVENT_PROPERTIES = [ @@ -37,28 +37,28 @@ const EVENT_PROPERTIES = ['type', 'bubbles', 'cancelable']; const NODES_WITH_VALUE = new Set(["input", "select", "option", "button", "li", "meter", "progress", "param"]); -export function serializeGenericEvent(e: Event): StringMap { +export function serializeGenericEvent(e: Event): {[key: string]: any} { return serializeEvent(e, EVENT_PROPERTIES); } // TODO(jteplitz602): Allow users to specify the properties they need rather than always // adding value and files #3374 -export function serializeEventWithTarget(e: Event): StringMap { +export function serializeEventWithTarget(e: Event): {[key: string]: any} { var serializedEvent = serializeEvent(e, EVENT_PROPERTIES); return addTarget(e, serializedEvent); } -export function serializeMouseEvent(e: MouseEvent): StringMap { +export function serializeMouseEvent(e: MouseEvent): {[key: string]: any} { return serializeEvent(e, MOUSE_EVENT_PROPERTIES); } -export function serializeKeyboardEvent(e: KeyboardEvent): StringMap { +export function serializeKeyboardEvent(e: KeyboardEvent): {[key: string]: any} { var serializedEvent = serializeEvent(e, KEYBOARD_EVENT_PROPERTIES); return addTarget(e, serializedEvent); } // TODO(jteplitz602): #3374. See above. -function addTarget(e: Event, serializedEvent: StringMap): StringMap { +function addTarget(e: Event, serializedEvent: {[key: string]: any}): {[key: string]: any} { if (NODES_WITH_VALUE.has((e.target).tagName.toLowerCase())) { var target = e.target; serializedEvent['target'] = {'value': target.value}; @@ -69,7 +69,7 @@ function addTarget(e: Event, serializedEvent: StringMap): StringMap return serializedEvent; } -function serializeEvent(e: any, properties: string[]): StringMap { +function serializeEvent(e: any, properties: string[]): {[key: string]: any} { var serialized = {}; for (var i = 0; i < properties.length; i++) { var prop = properties[i]; diff --git a/modules/angular2/src/web_workers/worker/application_common.ts b/modules/angular2/src/web_workers/worker/application_common.ts index 532d355090..4e2bfc9ab8 100644 --- a/modules/angular2/src/web_workers/worker/application_common.ts +++ b/modules/angular2/src/web_workers/worker/application_common.ts @@ -84,7 +84,7 @@ class PrintLogger { logGroupEnd() {} } -function webWorkerBindings(appComponentType, bus: MessageBus, initData: StringMap): +function webWorkerBindings(appComponentType, bus: MessageBus, initData: {[key: string]: any}): Array { return [ compilerBindings(), @@ -118,7 +118,7 @@ export function bootstrapWebWorkerCommon(appComponentType: Type, bus: MessageBus var subscription: any; var emitter = bus.from(SETUP_CHANNEL); - subscription = ObservableWrapper.subscribe(emitter, (message: StringMap) => { + subscription = ObservableWrapper.subscribe(emitter, (message: {[key: string]: any}) => { var bindings = [applicationCommonBindings(), webWorkerBindings(appComponentType, bus, message)]; if (isPresent(appBindings)) { diff --git a/modules/angular2/src/web_workers/worker/event_deserializer.ts b/modules/angular2/src/web_workers/worker/event_deserializer.ts index 9563ec0fa2..5fee619913 100644 --- a/modules/angular2/src/web_workers/worker/event_deserializer.ts +++ b/modules/angular2/src/web_workers/worker/event_deserializer.ts @@ -1,8 +1,6 @@ -import {StringMap} from "angular2/src/core/facade/collection"; - // no deserialization is necessary in TS. // This is only here to match dart interface -export function deserializeGenericEvent(serializedEvent: StringMap): - StringMap { +export function deserializeGenericEvent(serializedEvent: {[key: string]: any}): + {[key: string]: any} { return serializedEvent; } diff --git a/modules/angular2/src/web_workers/worker/event_dispatcher.ts b/modules/angular2/src/web_workers/worker/event_dispatcher.ts index e48a163a50..4048aa7eb9 100644 --- a/modules/angular2/src/web_workers/worker/event_dispatcher.ts +++ b/modules/angular2/src/web_workers/worker/event_dispatcher.ts @@ -38,7 +38,7 @@ class RenderEventData { eventName: string; locals: Map; - constructor(message: StringMap, serializer: Serializer) { + constructor(message: {[key: string]: any}, serializer: Serializer) { this.viewRef = serializer.deserialize(message['viewRef'], RenderViewRef); this.elementIndex = message['elementIndex']; this.eventName = message['eventName']; diff --git a/modules/angular2/test/core/change_detection/change_detector_config.ts b/modules/angular2/test/core/change_detection/change_detector_config.ts index e0a77f1111..94e5c9e0c3 100644 --- a/modules/angular2/test/core/change_detection/change_detector_config.ts +++ b/modules/angular2/test/core/change_detection/change_detector_config.ts @@ -176,7 +176,7 @@ class _ExpressionWithLocals { * Map from test id to _ExpressionWithLocals. * Tests in this map define an expression and local values which those expressions refer to. */ - static availableDefinitions: StringMap = { + static availableDefinitions: {[key: string]: _ExpressionWithLocals} = { 'valueFromLocals': new _ExpressionWithLocals( 'key', new Locals(null, MapWrapper.createFromPairs([['key', 'value']]))), 'functionFromLocals': new _ExpressionWithLocals( @@ -241,7 +241,7 @@ class _ExpressionWithMode { * Map from test id to _ExpressionWithMode. * Definitions in this map define conditions which allow testing various change detector modes. */ - static availableDefinitions: StringMap = { + static availableDefinitions: {[key: string]: _ExpressionWithMode} = { 'emptyUsingDefaultStrategy': new _ExpressionWithMode(ChangeDetectionStrategy.Default, false, false), 'emptyUsingOnPushStrategy': @@ -316,7 +316,7 @@ class _DirectiveUpdating { * Definitions in this map define definitions which allow testing directive updating. */ static availableDefinitions: - StringMap = { + {[key: string]: _DirectiveUpdating} = { 'directNoDispatcher': new _DirectiveUpdating( [_DirectiveUpdating.updateA('42', _DirectiveUpdating.basicRecords[0])], [_DirectiveUpdating.basicRecords[0]]), diff --git a/modules/angular2/test/core/compiler/runtime_metadata_spec.ts b/modules/angular2/test/core/compiler/runtime_metadata_spec.ts index 4a9b53d663..45e16b0d47 100644 --- a/modules/angular2/test/core/compiler/runtime_metadata_spec.ts +++ b/modules/angular2/test/core/compiler/runtime_metadata_spec.ts @@ -117,7 +117,7 @@ class DirectiveWithoutModuleId { class ComponentWithEverything implements OnChanges, OnInit, DoCheck, OnDestroy, AfterContentInit, AfterContentChecked, AfterViewInit, AfterViewChecked { - onChanges(changes: StringMap): void {} + onChanges(changes: {[key: string]: SimpleChange}): void {} onInit(): void {} doCheck(): void {} onDestroy(): void {} diff --git a/modules/angular2/test/core/compiler/schema_registry_mock.ts b/modules/angular2/test/core/compiler/schema_registry_mock.ts index c36f922f3d..4b7bc9ad95 100644 --- a/modules/angular2/test/core/compiler/schema_registry_mock.ts +++ b/modules/angular2/test/core/compiler/schema_registry_mock.ts @@ -1,10 +1,9 @@ import {ElementSchemaRegistry} from 'angular2/src/core/compiler/schema/element_schema_registry'; -import {StringMap} from 'angular2/src/core/facade/collection'; import {isPresent} from 'angular2/src/core/facade/lang'; export class MockSchemaRegistry implements ElementSchemaRegistry { - constructor(public existingProperties: StringMap, - public attrPropMapping: StringMap) {} + constructor(public existingProperties: {[key: string]: boolean}, + public attrPropMapping: {[key: string]: string}) {} hasProperty(tagName: string, property: string): boolean { var result = this.existingProperties[property]; return isPresent(result) ? result : true; diff --git a/modules/angular2/test/core/compiler/template_compiler_spec.ts b/modules/angular2/test/core/compiler/template_compiler_spec.ts index 7cb444e915..9d395afc13 100644 --- a/modules/angular2/test/core/compiler/template_compiler_spec.ts +++ b/modules/angular2/test/core/compiler/template_compiler_spec.ts @@ -325,10 +325,10 @@ function testableStylesModule(sourceModule: SourceModule): SourceModule { // Attention: read by eval! export function humanizeTemplate(template: CompiledTemplate, - humanizedTemplates: Map> = null): - StringMap { + humanizedTemplates: Map = null): + {[key: string]: any} { if (isBlank(humanizedTemplates)) { - humanizedTemplates = new Map>(); + humanizedTemplates = new Map(); } var result = humanizedTemplates.get(template.id); if (isPresent(result)) { @@ -369,7 +369,7 @@ function testChangeDetector(changeDetectorFactory: Function): string[] { class CommandHumanizer implements CommandVisitor { constructor(private result: any[], - private humanizedTemplates: Map>) {} + private humanizedTemplates: Map) {} visitText(cmd: TextCmd, context: any): any { this.result.push(`#text(${cmd.value})`); return null; diff --git a/modules/angular2/test/core/facade/collection_spec.ts b/modules/angular2/test/core/facade/collection_spec.ts index 8ef1eb325c..a04b005c76 100644 --- a/modules/angular2/test/core/facade/collection_spec.ts +++ b/modules/angular2/test/core/facade/collection_spec.ts @@ -1,11 +1,6 @@ import {describe, it, expect, beforeEach, ddescribe, iit, xit} from 'angular2/test_lib'; -import { - ListWrapper, - StringMap, - StringMapWrapper, - MapWrapper -} from 'angular2/src/core/facade/collection'; +import {ListWrapper, StringMapWrapper, MapWrapper} from 'angular2/src/core/facade/collection'; export function main() { describe('ListWrapper', () => { diff --git a/modules/angular2/test/router/route_recognizer_spec.ts b/modules/angular2/test/router/route_recognizer_spec.ts index 6ba8ea21c6..662b7c10b9 100644 --- a/modules/angular2/test/router/route_recognizer_spec.ts +++ b/modules/angular2/test/router/route_recognizer_spec.ts @@ -10,7 +10,7 @@ import { SpyObject } from 'angular2/test_lib'; -import {Map, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; +import {Map, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {RouteRecognizer} from 'angular2/src/router/route_recognizer'; import {ComponentInstruction} from 'angular2/src/router/instruction'; diff --git a/modules/angular2/test/web_workers/shared/web_worker_test_util.ts b/modules/angular2/test/web_workers/shared/web_worker_test_util.ts index 220c495033..a52b95e618 100644 --- a/modules/angular2/test/web_workers/shared/web_worker_test_util.ts +++ b/modules/angular2/test/web_workers/shared/web_worker_test_util.ts @@ -1,4 +1,4 @@ -import {StringMap, StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; +import {StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import { MessageBusSink, MessageBusSource, @@ -13,11 +13,11 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone'; * Such that whatever goes into one's sink comes out the others source. */ export function createPairedMessageBuses(): PairedMessageBuses { - var firstChannels: StringMap = {}; + var firstChannels: {[key: string]: MockEventEmitter} = {}; var workerMessageBusSink = new MockMessageBusSink(firstChannels); var uiMessageBusSource = new MockMessageBusSource(firstChannels); - var secondChannels: StringMap = {}; + var secondChannels: {[key: string]: MockEventEmitter} = {}; var uiMessageBusSink = new MockMessageBusSink(secondChannels); var workerMessageBusSource = new MockMessageBusSource(secondChannels); @@ -30,7 +30,7 @@ export class PairedMessageBuses { } export class MockMessageBusSource implements MessageBusSource { - constructor(private _channels: StringMap) {} + constructor(private _channels: {[key: string]: MockEventEmitter}) {} initChannel(channel: string, runInZone = true) { if (!StringMapWrapper.contains(this._channels, channel)) { @@ -49,7 +49,7 @@ export class MockMessageBusSource implements MessageBusSource { } export class MockMessageBusSink implements MessageBusSink { - constructor(private _channels: StringMap) {} + constructor(private _channels: {[key: string]: MockEventEmitter}) {} initChannel(channel: string, runInZone = true) { if (!StringMapWrapper.contains(this._channels, channel)) { diff --git a/modules/benchpress/src/measure_values.ts b/modules/benchpress/src/measure_values.ts index bbac9adcc4..28c67c9e57 100644 --- a/modules/benchpress/src/measure_values.ts +++ b/modules/benchpress/src/measure_values.ts @@ -1,9 +1,9 @@ import {Date, DateWrapper} from 'angular2/src/core/facade/lang'; -import {StringMap, Map} from 'angular2/src/core/facade/collection'; +import {Map} from 'angular2/src/core/facade/collection'; export class MeasureValues { constructor(public runIndex: number, public timeStamp: Date, - public values: StringMap) {} + public values: {[key: string]: any}) {} toJson() { return { diff --git a/modules/benchpress/src/metric.ts b/modules/benchpress/src/metric.ts index 5cc5cf4420..bebc223b6a 100644 --- a/modules/benchpress/src/metric.ts +++ b/modules/benchpress/src/metric.ts @@ -1,7 +1,6 @@ import {bind, Binding} from 'angular2/src/core/di'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; -import {StringMap} from 'angular2/src/core/facade/collection'; /** * A metric is measures values @@ -21,11 +20,11 @@ export abstract class Metric { * since the begin call. * @param restart: Whether to restart right after this. */ - endMeasure(restart: boolean): Promise> { throw new BaseException('NYI'); } + endMeasure(restart: boolean): Promise<{[key: string]: any}> { throw new BaseException('NYI'); } /** * Describes the metrics provided by this metric implementation. * (e.g. units, ...) */ - describe(): StringMap { throw new BaseException('NYI'); } + describe(): {[key: string]: any} { throw new BaseException('NYI'); } } diff --git a/modules/benchpress/src/metric/multi_metric.ts b/modules/benchpress/src/metric/multi_metric.ts index 923b736100..f7b80d2ec4 100644 --- a/modules/benchpress/src/metric/multi_metric.ts +++ b/modules/benchpress/src/metric/multi_metric.ts @@ -1,5 +1,5 @@ import {bind, Binding, Injector, OpaqueToken} from 'angular2/src/core/di'; -import {ListWrapper, StringMapWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; import {Metric} from '../metric'; @@ -29,7 +29,7 @@ export class MultiMetric extends Metric { * since the begin call. * @param restart: Whether to restart right after this. */ - endMeasure(restart: boolean): Promise> { + endMeasure(restart: boolean): Promise<{[key: string]: any}> { return PromiseWrapper.all( ListWrapper.map(this._metrics, (metric) => metric.endMeasure(restart))) .then((values) => { return mergeStringMaps(values); }); @@ -39,7 +39,7 @@ export class MultiMetric extends Metric { * Describes the metrics provided by this metric implementation. * (e.g. units, ...) */ - describe(): StringMap { + describe(): {[key: string]: any} { return mergeStringMaps(this._metrics.map((metric) => metric.describe())); } } diff --git a/modules/benchpress/src/metric/perflog_metric.ts b/modules/benchpress/src/metric/perflog_metric.ts index 0b750962aa..b183b36eca 100644 --- a/modules/benchpress/src/metric/perflog_metric.ts +++ b/modules/benchpress/src/metric/perflog_metric.ts @@ -8,7 +8,7 @@ import { NumberWrapper } from 'angular2/src/core/facade/lang'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; -import {ListWrapper, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection'; +import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import {bind, Binding, OpaqueToken} from 'angular2/src/core/di'; import {WebDriverExtension, PerfLogFeatures} from '../web_driver_extension'; @@ -24,7 +24,7 @@ export class PerflogMetric extends Metric { // TODO(tbosch): use static values when our transpiler supports them static get SET_TIMEOUT(): OpaqueToken { return _SET_TIMEOUT; } - private _remainingEvents: Array>; + private _remainingEvents: Array<{[key: string]: any}>; private _measureCount: number; _perfLogFeatures: PerfLogFeatures; @@ -35,7 +35,7 @@ export class PerflogMetric extends Metric { * @param microMetrics Name and description of metrics provided via console.time / console.timeEnd **/ constructor(private _driverExtension: WebDriverExtension, private _setTimeout: Function, - private _microMetrics: StringMap, private _forceGc: boolean, + private _microMetrics: {[key: string]: any}, private _forceGc: boolean, private _captureFrames: boolean) { super(); @@ -44,7 +44,7 @@ export class PerflogMetric extends Metric { this._perfLogFeatures = _driverExtension.perfLogFeatures(); } - describe(): StringMap { + describe(): {[key: string]: any} { var res = { 'scriptTime': 'script execution time in ms, including gc and render', 'pureScriptTime': 'script execution time in ms, without gc nor render' @@ -89,7 +89,7 @@ export class PerflogMetric extends Metric { return resultPromise.then((_) => this._beginMeasure()); } - endMeasure(restart: boolean): Promise> { + endMeasure(restart: boolean): Promise<{[key: string]: any}> { if (this._forceGc) { return this._endPlainMeasureAndMeasureForceGc(restart); } else { @@ -117,7 +117,7 @@ export class PerflogMetric extends Metric { return this._driverExtension.timeBegin(this._markName(this._measureCount++)); } - _endMeasure(restart: boolean): Promise> { + _endMeasure(restart: boolean): Promise<{[key: string]: any}> { var markName = this._markName(this._measureCount - 1); var nextMarkName = restart ? this._markName(this._measureCount++) : null; return this._driverExtension.timeEnd(markName, nextMarkName) @@ -171,7 +171,7 @@ export class PerflogMetric extends Metric { } } - _aggregateEvents(events: Array>, markName): StringMap { + _aggregateEvents(events: Array<{[key: string]: any}>, markName): {[key: string]: any} { var result = {'scriptTime': 0, 'pureScriptTime': 0}; if (this._perfLogFeatures.gc) { result['gcTime'] = 0; @@ -199,8 +199,8 @@ export class PerflogMetric extends Metric { var frameCaptureStartEvent = null; var frameCaptureEndEvent = null; - var intervalStarts: StringMap = {}; - var intervalStartCount: StringMap = {}; + var intervalStarts: {[key: string]: any} = {}; + var intervalStartCount: {[key: string]: number} = {}; events.forEach((event) => { var ph = event['ph']; var name = event['name']; @@ -307,7 +307,7 @@ export class PerflogMetric extends Metric { return result; } - _addFrameMetrics(result: StringMap, frameTimes: any[]) { + _addFrameMetrics(result: {[key: string]: any}, frameTimes: any[]) { result['frameTime.mean'] = ListWrapper.reduce(frameTimes, (a, b) => a + b, 0) / frameTimes.length; var firstFrame = frameTimes[0]; diff --git a/modules/benchpress/src/sample_description.ts b/modules/benchpress/src/sample_description.ts index 2788d2962f..ada4417dc8 100644 --- a/modules/benchpress/src/sample_description.ts +++ b/modules/benchpress/src/sample_description.ts @@ -1,4 +1,4 @@ -import {StringMapWrapper, ListWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection'; import {bind, Binding, OpaqueToken} from 'angular2/src/core/di'; import {Validator} from './validator'; import {Metric} from './metric'; @@ -10,10 +10,10 @@ import {Options} from './common_options'; export class SampleDescription { // TODO(tbosch): use static values when our transpiler supports them static get BINDINGS(): Binding[] { return _BINDINGS; } - description: StringMap; + description: {[key: string]: any}; - constructor(public id: string, descriptions: Array>, - public metrics: StringMap) { + constructor(public id: string, descriptions: Array<{[key: string]: any}>, + public metrics: {[key: string]: any}) { this.description = {}; ListWrapper.forEach(descriptions, (description) => { StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value); diff --git a/modules/benchpress/src/sampler.ts b/modules/benchpress/src/sampler.ts index 2ec1f16d1f..2e69366792 100644 --- a/modules/benchpress/src/sampler.ts +++ b/modules/benchpress/src/sampler.ts @@ -1,6 +1,5 @@ import {isPresent, isBlank, Date, DateWrapper} from 'angular2/src/core/facade/lang'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; -import {StringMapWrapper, StringMap, ListWrapper} from 'angular2/src/core/facade/collection'; import {bind, Binding, OpaqueToken} from 'angular2/src/core/di'; import {Metric} from './metric'; @@ -78,7 +77,7 @@ export class Sampler { .then((measureValues) => this._report(lastState, measureValues)); } - _report(state: SampleState, metricValues: StringMap): Promise { + _report(state: SampleState, metricValues: {[key: string]: any}): Promise { var measureValues = new MeasureValues(state.completeSample.length, this._now(), metricValues); var completeSample = state.completeSample.concat([measureValues]); var validSample = this._validator.validate(completeSample); diff --git a/modules/benchpress/src/validator.ts b/modules/benchpress/src/validator.ts index 16875f7187..8748f2f55d 100644 --- a/modules/benchpress/src/validator.ts +++ b/modules/benchpress/src/validator.ts @@ -1,5 +1,4 @@ import {bind, Binding} from 'angular2/src/core/di'; -import {StringMap} from 'angular2/src/core/facade/collection'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; import {MeasureValues} from './measure_values'; @@ -23,5 +22,5 @@ export abstract class Validator { * Returns a Map that describes the properties of the validator * (e.g. sample size, ...) */ - describe(): StringMap { throw new BaseException('NYI'); } + describe(): {[key: string]: any} { throw new BaseException('NYI'); } } diff --git a/modules/benchpress/src/validator/regression_slope_validator.ts b/modules/benchpress/src/validator/regression_slope_validator.ts index 8df70687b1..1d88463f3c 100644 --- a/modules/benchpress/src/validator/regression_slope_validator.ts +++ b/modules/benchpress/src/validator/regression_slope_validator.ts @@ -1,4 +1,4 @@ -import {ListWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {ListWrapper} from 'angular2/src/core/facade/collection'; import {bind, Binding, OpaqueToken} from 'angular2/src/core/di'; import {Validator} from '../validator'; @@ -26,7 +26,7 @@ export class RegressionSlopeValidator extends Validator { this._metric = metric; } - describe(): StringMap { + describe(): {[key: string]: any} { return {'sampleSize': this._sampleSize, 'regressionSlopeMetric': this._metric}; } diff --git a/modules/benchpress/src/validator/size_validator.ts b/modules/benchpress/src/validator/size_validator.ts index 6384f1e533..19af7a46d2 100644 --- a/modules/benchpress/src/validator/size_validator.ts +++ b/modules/benchpress/src/validator/size_validator.ts @@ -1,4 +1,4 @@ -import {ListWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {ListWrapper} from 'angular2/src/core/facade/collection'; import {bind, Binding, OpaqueToken} from 'angular2/src/core/di'; import {Validator} from '../validator'; @@ -20,7 +20,7 @@ export class SizeValidator extends Validator { this._sampleSize = size; } - describe(): StringMap { return {'sampleSize': this._sampleSize}; } + describe(): {[key: string]: any} { return {'sampleSize': this._sampleSize}; } validate(completeSample: MeasureValues[]): MeasureValues[] { if (completeSample.length >= this._sampleSize) { diff --git a/modules/benchpress/src/web_driver_extension.ts b/modules/benchpress/src/web_driver_extension.ts index 4286c3ae53..0c27a7a198 100644 --- a/modules/benchpress/src/web_driver_extension.ts +++ b/modules/benchpress/src/web_driver_extension.ts @@ -3,7 +3,7 @@ import {bind, Binding, Injector, OpaqueToken} from 'angular2/src/core/di'; import {isBlank, isPresent} from 'angular2/src/core/facade/lang'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; -import {ListWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {ListWrapper} from 'angular2/src/core/facade/collection'; import {Options} from './common_options'; @@ -61,7 +61,7 @@ export abstract class WebDriverExtension { perfLogFeatures(): PerfLogFeatures { throw new BaseException('NYI'); } - supports(capabilities: StringMap): boolean { return true; } + supports(capabilities: {[key: string]: any}): boolean { return true; } } export class PerfLogFeatures { diff --git a/modules/benchpress/src/webdriver/chrome_driver_extension.ts b/modules/benchpress/src/webdriver/chrome_driver_extension.ts index 91b875e1e9..0bf1153504 100644 --- a/modules/benchpress/src/webdriver/chrome_driver_extension.ts +++ b/modules/benchpress/src/webdriver/chrome_driver_extension.ts @@ -1,5 +1,5 @@ import {bind, Binding} from 'angular2/src/core/di'; -import {ListWrapper, StringMapWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection'; import { Json, isPresent, @@ -84,8 +84,8 @@ export class ChromeDriverExtension extends WebDriverExtension { }); } - private _convertPerfRecordsToEvents(chromeEvents: Array>, - normalizedEvents: Array> = null) { + private _convertPerfRecordsToEvents(chromeEvents: Array<{[key: string]: any}>, + normalizedEvents: Array<{[key: string]: any}> = null) { if (isBlank(normalizedEvents)) { normalizedEvents = []; } @@ -214,14 +214,14 @@ export class ChromeDriverExtension extends WebDriverExtension { return new PerfLogFeatures({render: true, gc: true, frameCapture: true}); } - supports(capabilities: StringMap): boolean { + supports(capabilities: {[key: string]: any}): boolean { return this._majorChromeVersion != -1 && StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'chrome'); } } -function normalizeEvent(chromeEvent: StringMap, data: StringMap): - StringMap { +function normalizeEvent(chromeEvent: {[key: string]: any}, data: {[key: string]: any}): + {[key: string]: any} { var ph = chromeEvent['ph']; if (StringWrapper.equals(ph, 'S')) { ph = 'b'; diff --git a/modules/benchpress/src/webdriver/firefox_driver_extension.ts b/modules/benchpress/src/webdriver/firefox_driver_extension.ts index 188bebb2fb..8d52c7c1ef 100644 --- a/modules/benchpress/src/webdriver/firefox_driver_extension.ts +++ b/modules/benchpress/src/webdriver/firefox_driver_extension.ts @@ -38,7 +38,7 @@ export class FirefoxDriverExtension extends WebDriverExtension { perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true, gc: true}); } - supports(capabilities: StringMap): boolean { + supports(capabilities: {[key: string]: any}): boolean { return StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'firefox'); } } diff --git a/modules/benchpress/src/webdriver/ios_driver_extension.ts b/modules/benchpress/src/webdriver/ios_driver_extension.ts index dc0683fc16..916071ddba 100644 --- a/modules/benchpress/src/webdriver/ios_driver_extension.ts +++ b/modules/benchpress/src/webdriver/ios_driver_extension.ts @@ -1,5 +1,5 @@ import {bind, Binding} from 'angular2/src/core/di'; -import {ListWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {ListWrapper} from 'angular2/src/core/facade/collection'; import { Json, isPresent, @@ -91,7 +91,7 @@ export class IOsDriverExtension extends WebDriverExtension { perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true}); } - supports(capabilities: StringMap): boolean { + supports(capabilities: {[key: string]: any}): boolean { return StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'safari'); } } diff --git a/modules/benchpress/test/metric/multi_metric_spec.ts b/modules/benchpress/test/metric/multi_metric_spec.ts index 8940dd9be3..3478ec0f66 100644 --- a/modules/benchpress/test/metric/multi_metric_spec.ts +++ b/modules/benchpress/test/metric/multi_metric_spec.ts @@ -11,7 +11,7 @@ import { xit, } from 'angular2/test_lib'; -import {ListWrapper, StringMap} from 'angular2/src/core/facade/collection'; +import {ListWrapper} from 'angular2/src/core/facade/collection'; import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async'; import {Metric, MultiMetric, bind, Injector} from 'benchpress/common'; @@ -70,13 +70,13 @@ class MockMetric extends Metric { beginMeasure(): Promise { return PromiseWrapper.resolve(`${this._id}_beginMeasure`); } - endMeasure(restart: boolean): Promise> { + endMeasure(restart: boolean): Promise<{[key: string]: any}> { var result = {}; result[this._id] = {'restart': restart}; return PromiseWrapper.resolve(result); } - describe(): StringMap { + describe(): {[key: string]: string} { var result = {}; result[this._id] = 'describe'; return result; diff --git a/modules/benchpress/test/reporter/multi_reporter_spec.ts b/modules/benchpress/test/reporter/multi_reporter_spec.ts index 80eb06729a..870a9570ef 100644 --- a/modules/benchpress/test/reporter/multi_reporter_spec.ts +++ b/modules/benchpress/test/reporter/multi_reporter_spec.ts @@ -11,7 +11,7 @@ import { xit, } from 'angular2/test_lib'; -import {ListWrapper, StringMap} from 'angular2/src/core/facade/collection'; +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'; @@ -65,12 +65,12 @@ export function main() { class MockReporter extends Reporter { constructor(private _id: string) { super(); } - reportMeasureValues(values: MeasureValues): Promise> { + reportMeasureValues(values: MeasureValues): Promise<{[key: string]: any}> { return PromiseWrapper.resolve({'id': this._id, 'values': values}); } reportSample(completeSample: MeasureValues[], - validSample: MeasureValues[]): Promise> { + validSample: MeasureValues[]): Promise<{[key: string]: any}> { return PromiseWrapper.resolve( {'id': this._id, 'completeSample': completeSample, 'validSample': validSample}); } diff --git a/modules/benchpress/test/web_driver_extension_spec.ts b/modules/benchpress/test/web_driver_extension_spec.ts index 61b24c7e14..929fb5ee47 100644 --- a/modules/benchpress/test/web_driver_extension_spec.ts +++ b/modules/benchpress/test/web_driver_extension_spec.ts @@ -11,7 +11,7 @@ import { xit, } from 'angular2/test_lib'; -import {StringMap, ListWrapper} from 'angular2/src/core/facade/collection'; +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'; @@ -57,7 +57,7 @@ class MockExtension extends WebDriverExtension { this.id = id; } - supports(capabilities: StringMap): boolean { + supports(capabilities: {[key: string]: any}): boolean { return StringWrapper.equals(capabilities['browser'], this.id); } } diff --git a/modules/examples/src/model_driven_forms/index.ts b/modules/examples/src/model_driven_forms/index.ts index df673e6e3a..fe59aeb6d8 100644 --- a/modules/examples/src/model_driven_forms/index.ts +++ b/modules/examples/src/model_driven_forms/index.ts @@ -18,7 +18,7 @@ import {RegExpWrapper, print, isPresent} from 'angular2/src/core/facade/lang'; /** * Custom validator. */ -function creditCardValidator(c): StringMap { +function creditCardValidator(c): {[key: string]: boolean} { if (isPresent(c.value) && RegExpWrapper.test(/^\d{16}$/g, c.value)) { return null; } else { diff --git a/modules/examples/src/template_driven_forms/index.ts b/modules/examples/src/template_driven_forms/index.ts index de78a7bccc..15ea90b910 100644 --- a/modules/examples/src/template_driven_forms/index.ts +++ b/modules/examples/src/template_driven_forms/index.ts @@ -35,7 +35,7 @@ class CheckoutModel { /** * Custom validator. */ -function creditCardValidator(c): StringMap { +function creditCardValidator(c): {[key: string]: boolean} { if (isPresent(c.value) && RegExpWrapper.test(/^\d{16}$/g, c.value)) { return null; } else { diff --git a/npm-shrinkwrap.clean.json b/npm-shrinkwrap.clean.json index bb71977bcb..e4b088d435 100644 --- a/npm-shrinkwrap.clean.json +++ b/npm-shrinkwrap.clean.json @@ -10026,7 +10026,7 @@ } }, "ts2dart": { - "version": "0.7.10", + "version": "0.7.11", "dependencies": { "source-map": { "version": "0.4.4", diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 7efdf5673e..fc56878637 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -15496,9 +15496,9 @@ } }, "ts2dart": { - "version": "0.7.10", - "from": "https://registry.npmjs.org/ts2dart/-/ts2dart-0.7.10.tgz", - "resolved": "https://registry.npmjs.org/ts2dart/-/ts2dart-0.7.10.tgz", + "version": "0.7.11", + "from": "https://registry.npmjs.org/ts2dart/-/ts2dart-0.7.11.tgz", + "resolved": "https://registry.npmjs.org/ts2dart/-/ts2dart-0.7.11.tgz", "dependencies": { "source-map": { "version": "0.4.4", diff --git a/package.json b/package.json index b3d9656b09..91ddcd4990 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "temp": "^0.8.1", "ternary-stream": "^1.2.3", "through2": "^0.6.1", - "ts2dart": "^0.7.10", + "ts2dart": "^0.7.11", "tsd": "^0.6.5-beta", "tslint": "^2.5.0", "typescript": "^1.6.2",