chore(typings): remove StringMap

This was a poorly typed attempt to mimic TypeScript's index signatures,
which we can use instead.
This eliminates a very strange type that we were exposing to users, but
not re-exporting through our public API.

Fixes #4483
This commit is contained in:
Alex Eagle
2015-10-02 16:47:54 -07:00
committed by Alex Eagle
parent 2ebc74ddcc
commit 7c4199cd1c
76 changed files with 231 additions and 291 deletions

View File

@ -278,7 +278,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
this.dispatcher.logBindingUpdate(this._currentBinding(), value);
}
addChange(changes: StringMap<string, any>, oldValue: any, newValue: any): StringMap<string, any> {
addChange(changes: {[key: string]: any}, oldValue: any, newValue: any): {[key: string]: any} {
if (isBlank(changes)) {
changes = {};
}

View File

@ -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<any, any> {
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]);

View File

@ -34,12 +34,12 @@ export class CompileTypeMetadata {
this.isHost = normalizeBool(isHost);
}
static fromJson(data: StringMap<string, any>): CompileTypeMetadata {
static fromJson(data: {[key: string]: any}): CompileTypeMetadata {
return new CompileTypeMetadata(
{name: data['name'], moduleUrl: data['moduleUrl'], isHost: data['isHost']});
}
toJson(): StringMap<string, any> {
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<string, any>): 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<string, any> {
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<string, string>,
host?: {[key: string]: string},
lifecycleHooks?: LifecycleHooks[],
template?: CompileTemplateMetadata
} = {}): CompileDirectiveMetadata {
@ -169,11 +169,11 @@ export class CompileDirectiveMetadata {
selector: string;
exportAs: string;
changeDetection: ChangeDetectionStrategy;
inputs: StringMap<string, string>;
outputs: StringMap<string, string>;
hostListeners: StringMap<string, string>;
hostProperties: StringMap<string, string>;
hostAttributes: StringMap<string, string>;
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<string, string>,
outputs?: StringMap<string, string>,
hostListeners?: StringMap<string, string>,
hostProperties?: StringMap<string, string>,
hostAttributes?: StringMap<string, string>,
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<string, any>): 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<string, any> {
toJson(): {[key: string]: any} {
return {
'isComponent': this.isComponent,
'dynamicLoadable': this.dynamicLoadable,

View File

@ -436,8 +436,8 @@ class TemplateParseVisitor implements HtmlAstVisitor {
return directiveAsts;
}
private _createDirectiveHostPropertyAsts(elementName: string,
hostProps: StringMap<string, string>, 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<string, string>,
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<string, string>,
private _createDirectivePropertyAsts(directiveProperties: {[key: string]: string},
boundProps: BoundElementOrDirectiveProperty[],
targetBoundDirectiveProps: BoundDirectivePropertyAst[]) {
if (isPresent(directiveProperties)) {

View File

@ -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<string, string>;
attrToPropMap: {[key: string]: string};
abstract parse(templateHtml: string);
abstract query(selector: string): any;

View File

@ -115,9 +115,9 @@ export class Parse5DomAdapter extends DomAdapter {
return result;
}
on(el, evt, listener) {
var listenersMap: StringMap<any, any> = el._eventListenersMap;
var listenersMap: {[k: /*any*/ string]: any} = el._eventListenersMap;
if (isBlank(listenersMap)) {
var listenersMap: StringMap<any, any> = 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<string, any> = StringMapWrapper.create();
var rule: {[key: string]: any} = StringMapWrapper.create();
StringMapWrapper.set(rule, "cssText", css);
StringMapWrapper.set(rule, "style", {content: "", cssText: ""});
if (parsedRule.type == "rule") {

View File

@ -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<any, any>, getValues: boolean): any[]} = (function()
export class MapWrapper {
static clone<K, V>(m: Map<K, V>): Map<K, V> { return createMapFromMap(m); }
static createFromStringMap<T>(stringMap: StringMap<string, T>): Map<string, T> {
static createFromStringMap<T>(stringMap: {[key: string]: T}): Map<string, T> {
var result = new Map<string, T>();
for (var prop in stringMap) {
result.set(prop, stringMap[prop]);
}
return result;
}
static toStringMap<T>(m: Map<string, T>): StringMap<string, T> {
static toStringMap<T>(m: Map<string, T>): {[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<any, any> {
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<string, any>, key: string): boolean {
static contains(map: {[key: string]: any}, key: string): boolean {
return map.hasOwnProperty(key);
}
static get<V>(map: StringMap<string, V>, key: string): V {
static get<V>(map: {[key: string]: V}, key: string): V {
return map.hasOwnProperty(key) ? map[key] : undefined;
}
static set<V>(map: StringMap<string, V>, key: string, value: V) { map[key] = value; }
static keys(map: StringMap<string, any>): string[] { return Object.keys(map); }
static isEmpty(map: StringMap<string, any>): boolean {
static set<V>(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<string, any>, key: string) { delete map[key]; }
static forEach<K, V>(map: StringMap<string, V>, callback: /*(V, K) => void*/ Function) {
static delete (map: {[key: string]: any}, key: string) { delete map[key]; }
static forEach<K, V>(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<V>(m1: StringMap<string, V>, m2: StringMap<string, V>): StringMap<string, V> {
static merge<V>(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<V>(m1: StringMap<string, V>, m2: StringMap<string, V>): boolean {
static equals<V>(m1: {[key: string]: V}, m2: {[key: string]: V}): boolean {
var k1 = Object.keys(m1);
var k2 = Object.keys(m2);
if (k1.length != k2.length) {

View File

@ -8,7 +8,7 @@ export class AbstractControlDirective {
get valid(): boolean { return isPresent(this.control) ? this.control.valid : null; }
get errors(): StringMap<string, any> {
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; }
}
}

View File

@ -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<string, SimpleChange>) {
onChanges(changes: {[key: string]: SimpleChange}) {
if (!this._added) {
this.formDirective.addControl(this);
this._added = true;

View File

@ -98,7 +98,7 @@ export class NgForm extends ControlContainer implements Form {
get path(): string[] { return []; }
get controls(): StringMap<string, AbstractControl> { return this.form.controls; }
get controls(): {[key: string]: AbstractControl} { return this.form.controls; }
addControl(dir: NgControl): void {
this._later(_ => {

View File

@ -84,7 +84,7 @@ export class NgFormControl extends NgControl implements OnChanges {
this.valueAccessor = selectValueAccessor(this, valueAccessors);
}
onChanges(changes: StringMap<string, SimpleChange>): void {
onChanges(changes: {[key: string]: SimpleChange}): void {
if (!this._added) {
setUpControl(this.form, this);
this.form.updateValidity();

View File

@ -55,7 +55,7 @@ export class NgModel extends NgControl implements OnChanges {
this.valueAccessor = selectValueAccessor(this, valueAccessors);
}
onChanges(changes: StringMap<string, SimpleChange>) {
onChanges(changes: {[key: string]: SimpleChange}) {
if (!this._added) {
setUpControl(this._control, this);
this._control.updateValidity();

View File

@ -51,7 +51,7 @@ export function setProperty(renderer: Renderer, elementRef: ElementRef, propName
renderer.setElementProperty(elementRef, propName, propValue);
}
export function isPropertyUpdated(changes: StringMap<string, any>, viewModel: any): boolean {
export function isPropertyUpdated(changes: {[key: string]: any}, viewModel: any): boolean {
if (!StringMapWrapper.contains(changes, "model")) return false;
var change = changes["model"];

View File

@ -66,8 +66,8 @@ import * as modelModule from './model';
*/
@Injectable()
export class FormBuilder {
group(controlsConfig: StringMap<string, any>,
extra: StringMap<string, any> = 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<string, modelModule.AbstractControl> {
_reduceControls(controlsConfig: any): {[key: string]: modelModule.AbstractControl} {
var controls = {};
StringMapWrapper.forEach(controlsConfig, (controlConfig, controlName) => {
controls[controlName] = this._createControl(controlConfig);

View File

@ -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 | number>| string) {
export class AbstractControl {
_value: any;
_status: string;
_errors: StringMap<string, any>;
_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<string, any> { 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<string, boolean>;
private _optionals: {[key: string]: boolean};
constructor(public controls: StringMap<string, AbstractControl>,
optionals: StringMap<string, boolean> = 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();

View File

@ -17,11 +17,11 @@ export const NG_VALIDATORS: OpaqueToken = CONST_EXPR(new OpaqueToken("NgValidato
* ```
*/
export class Validators {
static required(control: modelModule.Control): StringMap<string, boolean> {
static required(control: modelModule.Control): {[key: string]: boolean} {
return isBlank(control.value) || control.value == "" ? {"required": true} : null;
}
static nullValidator(c: any): StringMap<string, boolean> { 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<string, boolean> {
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<string, boolean> {
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<string, any[]>): void {
static _mergeErrors(control: modelModule.AbstractControl, res: {[key: string]: any[]}): void {
StringMapWrapper.forEach(control.errors, (value, error) => {
if (!StringMapWrapper.contains(res, error)) {
res[error] = [];

View File

@ -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<string, any[]>): 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<string, string>,
queries: StringMap<string, any>): 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;

View File

@ -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<string, SimpleChange>); }
export interface OnChanges { onChanges(changes: {[key: string]: SimpleChange}); }
/**
* Implement this interface to execute custom initialization logic after your directive's

View File

@ -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<string, any> {
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); }
}
}

View File

@ -151,11 +151,11 @@ export interface DirectiveFactory {
outputs?: string[],
properties?: string[],
events?: string[],
host?: StringMap<string, string>,
host?: {[key: string]: string},
bindings?: any[],
exportAs?: string,
moduleId?: string,
queries?: StringMap<string, any>
queries?: {[key: string]: any}
}): DirectiveDecorator;
new (obj: {
selector?: string,
@ -163,11 +163,11 @@ export interface DirectiveFactory {
outputs?: string[],
properties?: string[],
events?: string[],
host?: StringMap<string, string>,
host?: {[key: string]: string},
bindings?: any[],
exportAs?: string,
moduleId?: string,
queries?: StringMap<string, any>
queries?: {[key: string]: any}
}): DirectiveMetadata;
}
@ -221,11 +221,11 @@ export interface ComponentFactory {
outputs?: string[],
properties?: string[],
events?: string[],
host?: StringMap<string, string>,
host?: {[key: string]: string},
bindings?: any[],
exportAs?: string,
moduleId?: string,
queries?: StringMap<string, any>,
queries?: {[key: string]: any},
viewBindings?: any[],
changeDetection?: ChangeDetectionStrategy,
}): ComponentDecorator;
@ -235,11 +235,11 @@ export interface ComponentFactory {
outputs?: string[],
properties?: string[],
events?: string[],
host?: StringMap<string, string>,
host?: {[key: string]: string},
bindings?: any[],
exportAs?: string,
moduleId?: string,
queries?: StringMap<string, any>,
queries?: {[key: string]: any},
viewBindings?: any[],
changeDetection?: ChangeDetectionStrategy,
}): ComponentMetadata;

View File

@ -632,7 +632,7 @@ export class DirectiveMetadata extends InjectableMetadata {
* }
* ```
*/
host: StringMap<string, string>;
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<string, any>;
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<string, string>,
host?: {[key: string]: string},
bindings?: any[],
exportAs?: string,
moduleId?: string,
queries?: StringMap<string, any>
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<string, string>,
host?: {[key: string]: string},
bindings?: any[],
exportAs?: string,
moduleId?: string,
viewBindings?: any[],
queries?: StringMap<string, any>,
queries?: {[key: string]: any},
changeDetection?: ChangeDetectionStrategy,
} = {}) {
super({

View File

@ -23,7 +23,7 @@ export class ProtoPipes {
/**
* Map of {@link PipeMetadata} names to {@link PipeMetadata} implementations.
*/
public config: StringMap<string, PipeBinding>) {
public config: {[key: string]: PipeBinding}) {
this.config = config;
}
@ -37,7 +37,7 @@ export class ProtoPipes {
export class Pipes implements cd.Pipes {
_config: StringMap<string, cd.SelectedPipe> = {};
_config: {[key: string]: cd.SelectedPipe} = {};
constructor(public proto: ProtoPipes, public injector: Injector) {}

View File

@ -7,7 +7,7 @@ export interface PlatformReflectionCapabilities {
interfaces(type: Type): any[];
parameters(type: any): any[][];
annotations(type: any): any[];
propMetadata(typeOrFunc: any): StringMap<string, any[]>;
propMetadata(typeOrFunc: any): {[key: string]: any[]};
getter(name: string): GetterFn;
setter(name: string): SetterFn;
method(name: string): MethodFn;

View File

@ -134,7 +134,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return [];
}
propMetadata(typeOrFunc: any): StringMap<string, any[]> {
propMetadata(typeOrFunc: any): {[key: string]: any[]} {
// Prefer the direct API.
if (isPresent((<any>typeOrFunc).propMetadata)) {
var propMetadata = (<any>typeOrFunc).propMetadata;

View File

@ -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<string, any[]>) {}
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<string, GetterFn>): void {
_mergeMaps(this._getters, getters);
}
registerGetters(getters: {[key: string]: GetterFn}): void { _mergeMaps(this._getters, getters); }
registerSetters(setters: StringMap<string, SetterFn>): void {
_mergeMaps(this._setters, setters);
}
registerSetters(setters: {[key: string]: SetterFn}): void { _mergeMaps(this._setters, setters); }
registerMethods(methods: StringMap<string, MethodFn>): 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<string, any[]> {
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<any, any>, config: StringMap<string, Function>): void {
function _mergeMaps(target: Map<any, any>, config: {[key: string]: Function}): void {
StringMapWrapper.forEach(config, (v, k) => target.set(k, v));
}

View File

@ -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<string, Function> = {
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<string, string> {
static parseEventName(eventName: string): {[key: string]: string} {
var parts = eventName.toLowerCase().split('.');
var domEventName = ListWrapper.removeAt(parts, 0);