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

@ -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<string, any> {
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<string, any> {
export function serializeEventWithTarget(e: Event): {[key: string]: any} {
var serializedEvent = serializeEvent(e, EVENT_PROPERTIES);
return addTarget(e, serializedEvent);
}
export function serializeMouseEvent(e: MouseEvent): StringMap<string, any> {
export function serializeMouseEvent(e: MouseEvent): {[key: string]: any} {
return serializeEvent(e, MOUSE_EVENT_PROPERTIES);
}
export function serializeKeyboardEvent(e: KeyboardEvent): StringMap<string, any> {
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<string, any>): StringMap<string, any> {
function addTarget(e: Event, serializedEvent: {[key: string]: any}): {[key: string]: any} {
if (NODES_WITH_VALUE.has((<HTMLElement>e.target).tagName.toLowerCase())) {
var target = <HTMLInputElement>e.target;
serializedEvent['target'] = {'value': target.value};
@ -69,7 +69,7 @@ function addTarget(e: Event, serializedEvent: StringMap<string, any>): StringMap
return serializedEvent;
}
function serializeEvent(e: any, properties: string[]): StringMap<string, any> {
function serializeEvent(e: any, properties: string[]): {[key: string]: any} {
var serialized = {};
for (var i = 0; i < properties.length; i++) {
var prop = properties[i];