Skip to content

Commit 7c4199c

Browse files
committed
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 angular#4483
1 parent 2ebc74d commit 7c4199c

File tree

76 files changed

+231
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+231
-291
lines changed

docs/typescript-definition-package/templates/angular2/angular2.d.ts.template.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{% block staticDeclarations %}
33

44
interface Map<K,V> {}
5-
interface StringMap<K,V> extends Map<K,V> {}
65

76
{% for alias, module in doc.moduleDocs %}
87
declare module {$ module.namespace $} {

modules/angular2/manual_typings/globals.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
/// <reference path="../typings/zone/zone.d.ts"/>
66
declare var assert: any;
77

8-
// FIXME: K must be string!
9-
// FIXME: should have an index signature, `[k: string]: V;`
10-
interface StringMap<K extends string, V> {}
11-
128
interface BrowserNodeGlobal {
139
Object: typeof Object;
1410
Array: typeof Array;

modules/angular2/src/animate/animation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class Animation {
9696
* Applies the provided styles to the element
9797
* @param styles
9898
*/
99-
applyStyles(styles: StringMap<string, any>): void {
99+
applyStyles(styles: {[key: string]: any}): void {
100100
StringMapWrapper.forEach(styles, (value, key) => {
101101
var dashCaseKey = camelCaseToDashCase(key);
102102
if (isPresent(DOM.getStyle(this.element, dashCaseKey))) {

modules/angular2/src/animate/css_animation_builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ export class CssAnimationBuilder {
6161
* @param from
6262
* @param to
6363
*/
64-
setStyles(from: StringMap<string, any>, to: StringMap<string, any>): CssAnimationBuilder {
64+
setStyles(from: {[key: string]: any}, to: {[key: string]: any}): CssAnimationBuilder {
6565
return this.setFromStyles(from).setToStyles(to);
6666
}
6767

6868
/**
6969
* Sets the initial styles for the animation
7070
* @param from
7171
*/
72-
setFromStyles(from: StringMap<string, any>): CssAnimationBuilder {
72+
setFromStyles(from: {[key: string]: any}): CssAnimationBuilder {
7373
this.data.fromStyles = from;
7474
return this;
7575
}
@@ -78,7 +78,7 @@ export class CssAnimationBuilder {
7878
* Sets the destination styles for the animation
7979
* @param to
8080
*/
81-
setToStyles(to: StringMap<string, any>): CssAnimationBuilder {
81+
setToStyles(to: {[key: string]: any}): CssAnimationBuilder {
8282
this.data.toStyles = to;
8383
return this;
8484
}

modules/angular2/src/animate/css_animation_options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export class CssAnimationOptions {
22
/** initial styles for the element */
3-
fromStyles: StringMap<string, any>;
3+
fromStyles: {[key: string]: any};
44

55
/** destination styles for the element */
6-
toStyles: StringMap<string, any>;
6+
toStyles: {[key: string]: any};
77

88
/** classes to be added to the element */
99
classesToAdd: string[] = [];

modules/angular2/src/core/change_detection/abstract_change_detector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
278278
this.dispatcher.logBindingUpdate(this._currentBinding(), value);
279279
}
280280

281-
addChange(changes: StringMap<string, any>, oldValue: any, newValue: any): StringMap<string, any> {
281+
addChange(changes: {[key: string]: any}, oldValue: any, newValue: any): {[key: string]: any} {
282282
if (isBlank(changes)) {
283283
changes = {};
284284
}

modules/angular2/src/core/change_detection/change_detection_util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class ChangeDetectionUtil {
124124
static cond(cond, trueVal, falseVal): any { return cond ? trueVal : falseVal; }
125125

126126
static mapFn(keys: any[]): any {
127-
function buildMap(values): StringMap<any, any> {
127+
function buildMap(values): {[k: /*any*/ string]: any} {
128128
var res = StringMapWrapper.create();
129129
for (var i = 0; i < keys.length; ++i) {
130130
StringMapWrapper.set(res, keys[i], values[i]);

modules/angular2/src/core/compiler/directive_metadata.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ export class CompileTypeMetadata {
3434
this.isHost = normalizeBool(isHost);
3535
}
3636

37-
static fromJson(data: StringMap<string, any>): CompileTypeMetadata {
37+
static fromJson(data: {[key: string]: any}): CompileTypeMetadata {
3838
return new CompileTypeMetadata(
3939
{name: data['name'], moduleUrl: data['moduleUrl'], isHost: data['isHost']});
4040
}
4141

42-
toJson(): StringMap<string, any> {
42+
toJson(): {[key: string]: any} {
4343
return {
4444
// Note: Runtime type can't be serialized...
4545
'name': this.name,
@@ -72,7 +72,7 @@ export class CompileTemplateMetadata {
7272
this.ngContentSelectors = isPresent(ngContentSelectors) ? ngContentSelectors : [];
7373
}
7474

75-
static fromJson(data: StringMap<string, any>): CompileTemplateMetadata {
75+
static fromJson(data: {[key: string]: any}): CompileTemplateMetadata {
7676
return new CompileTemplateMetadata({
7777
encapsulation: isPresent(data['encapsulation']) ?
7878
VIEW_ENCAPSULATION_VALUES[data['encapsulation']] :
@@ -85,7 +85,7 @@ export class CompileTemplateMetadata {
8585
});
8686
}
8787

88-
toJson(): StringMap<string, any> {
88+
toJson(): {[key: string]: any} {
8989
return {
9090
'encapsulation':
9191
isPresent(this.encapsulation) ? serializeEnum(this.encapsulation) : this.encapsulation,
@@ -109,7 +109,7 @@ export class CompileDirectiveMetadata {
109109
changeDetection?: ChangeDetectionStrategy,
110110
inputs?: string[],
111111
outputs?: string[],
112-
host?: StringMap<string, string>,
112+
host?: {[key: string]: string},
113113
lifecycleHooks?: LifecycleHooks[],
114114
template?: CompileTemplateMetadata
115115
} = {}): CompileDirectiveMetadata {
@@ -169,11 +169,11 @@ export class CompileDirectiveMetadata {
169169
selector: string;
170170
exportAs: string;
171171
changeDetection: ChangeDetectionStrategy;
172-
inputs: StringMap<string, string>;
173-
outputs: StringMap<string, string>;
174-
hostListeners: StringMap<string, string>;
175-
hostProperties: StringMap<string, string>;
176-
hostAttributes: StringMap<string, string>;
172+
inputs: {[key: string]: string};
173+
outputs: {[key: string]: string};
174+
hostListeners: {[key: string]: string};
175+
hostProperties: {[key: string]: string};
176+
hostAttributes: {[key: string]: string};
177177
lifecycleHooks: LifecycleHooks[];
178178
template: CompileTemplateMetadata;
179179
constructor({type, isComponent, dynamicLoadable, selector, exportAs, changeDetection, inputs,
@@ -184,11 +184,11 @@ export class CompileDirectiveMetadata {
184184
selector?: string,
185185
exportAs?: string,
186186
changeDetection?: ChangeDetectionStrategy,
187-
inputs?: StringMap<string, string>,
188-
outputs?: StringMap<string, string>,
189-
hostListeners?: StringMap<string, string>,
190-
hostProperties?: StringMap<string, string>,
191-
hostAttributes?: StringMap<string, string>,
187+
inputs?: {[key: string]: string},
188+
outputs?: {[key: string]: string},
189+
hostListeners?: {[key: string]: string},
190+
hostProperties?: {[key: string]: string},
191+
hostAttributes?: {[key: string]: string},
192192
lifecycleHooks?: LifecycleHooks[],
193193
template?: CompileTemplateMetadata
194194
} = {}) {
@@ -207,7 +207,7 @@ export class CompileDirectiveMetadata {
207207
this.template = template;
208208
}
209209

210-
static fromJson(data: StringMap<string, any>): CompileDirectiveMetadata {
210+
static fromJson(data: {[key: string]: any}): CompileDirectiveMetadata {
211211
return new CompileDirectiveMetadata({
212212
isComponent: data['isComponent'],
213213
dynamicLoadable: data['dynamicLoadable'],
@@ -229,7 +229,7 @@ export class CompileDirectiveMetadata {
229229
});
230230
}
231231

232-
toJson(): StringMap<string, any> {
232+
toJson(): {[key: string]: any} {
233233
return {
234234
'isComponent': this.isComponent,
235235
'dynamicLoadable': this.dynamicLoadable,

modules/angular2/src/core/compiler/template_parser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ class TemplateParseVisitor implements HtmlAstVisitor {
436436
return directiveAsts;
437437
}
438438

439-
private _createDirectiveHostPropertyAsts(elementName: string,
440-
hostProps: StringMap<string, string>, sourceInfo: string,
439+
private _createDirectiveHostPropertyAsts(elementName: string, hostProps: {[key: string]: string},
440+
sourceInfo: string,
441441
targetPropertyAsts: BoundElementPropertyAst[]) {
442442
if (isPresent(hostProps)) {
443443
StringMapWrapper.forEach(hostProps, (expression, propName) => {
@@ -448,16 +448,16 @@ class TemplateParseVisitor implements HtmlAstVisitor {
448448
}
449449
}
450450

451-
private _createDirectiveHostEventAsts(hostListeners: StringMap<string, string>,
452-
sourceInfo: string, targetEventAsts: BoundEventAst[]) {
451+
private _createDirectiveHostEventAsts(hostListeners: {[key: string]: string}, sourceInfo: string,
452+
targetEventAsts: BoundEventAst[]) {
453453
if (isPresent(hostListeners)) {
454454
StringMapWrapper.forEach(hostListeners, (expression, propName) => {
455455
this._parseEvent(propName, expression, sourceInfo, [], targetEventAsts);
456456
});
457457
}
458458
}
459459

460-
private _createDirectivePropertyAsts(directiveProperties: StringMap<string, string>,
460+
private _createDirectivePropertyAsts(directiveProperties: {[key: string]: string},
461461
boundProps: BoundElementOrDirectiveProperty[],
462462
targetBoundDirectiveProps: BoundDirectivePropertyAst[]) {
463463
if (isPresent(directiveProperties)) {

modules/angular2/src/core/dom/dom_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export abstract class DomAdapter {
2727
* Maps attribute names to their corresponding property names for cases
2828
* where attribute name doesn't match property name.
2929
*/
30-
attrToPropMap: StringMap<string, string>;
30+
attrToPropMap: {[key: string]: string};
3131

3232
abstract parse(templateHtml: string);
3333
abstract query(selector: string): any;

0 commit comments

Comments
 (0)