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,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<string, string>) {}
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<string, Instruction>) {}
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<string, any> = null) {}
private _recognizer: PathRecognizer, public params: {[key: string]: any} = null) {}
/**
* Returns the component type of the represented route, or `null` if this instruction

View File

@ -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<string, string> = {};
keys: StringMap<string, boolean> = {};
map: {[key: string]: string} = {};
keys: {[key: string]: boolean} = {};
constructor(map: StringMap<string, any>) {
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<string, any> {
var unused: StringMap<string, any> = 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<string, any> {
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<string, any>): 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<string, any>): ComponentInstruction {
params: {[key: string]: any}): ComponentInstruction {
var hashKey = urlPath + '?' + urlParams.join('?');
if (this._cache.has(hashKey)) {
return this._cache.get(hashKey);

View File

@ -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';

View File

@ -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,

View File

@ -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';

View File

@ -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<string, any> = 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<string, any> = 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<string, any> {
parseQueryParams(): {[key: string]: any} {
var params = {};
this.capture('?');
this.parseParam(params);
@ -160,7 +160,7 @@ export class UrlParser {
return params;
}
parseMatrixParams(): StringMap<string, any> {
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<string, any>): 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, any>): string[] {
export function serializeParams(paramMap: {[key: string]: any}): string[] {
var params = [];
if (isPresent(paramMap)) {
StringMapWrapper.forEach(paramMap, (value, key) => {