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:
@ -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<string, any>) {}
|
||||
public values: {[key: string]: any}) {}
|
||||
|
||||
toJson() {
|
||||
return {
|
||||
|
@ -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<StringMap<string, any>> { 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<string, any> { throw new BaseException('NYI'); }
|
||||
describe(): {[key: string]: any} { throw new BaseException('NYI'); }
|
||||
}
|
||||
|
@ -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<StringMap<string, any>> {
|
||||
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<string, any> {
|
||||
describe(): {[key: string]: any} {
|
||||
return mergeStringMaps(this._metrics.map((metric) => metric.describe()));
|
||||
}
|
||||
}
|
||||
|
@ -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<StringMap<string, any>>;
|
||||
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<string, any>, 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<string, any> {
|
||||
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<StringMap<string, any>> {
|
||||
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<StringMap<string, any>> {
|
||||
_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<StringMap<string, any>>, markName): StringMap<string, any> {
|
||||
_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<string, any> = {};
|
||||
var intervalStartCount: StringMap<string, number> = {};
|
||||
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<string, any>, 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];
|
||||
|
@ -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<string, any>;
|
||||
description: {[key: string]: any};
|
||||
|
||||
constructor(public id: string, descriptions: Array<StringMap<string, any>>,
|
||||
public metrics: StringMap<string, any>) {
|
||||
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);
|
||||
|
@ -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<string, any>): Promise<SampleState> {
|
||||
_report(state: SampleState, metricValues: {[key: string]: any}): Promise<SampleState> {
|
||||
var measureValues = new MeasureValues(state.completeSample.length, this._now(), metricValues);
|
||||
var completeSample = state.completeSample.concat([measureValues]);
|
||||
var validSample = this._validator.validate(completeSample);
|
||||
|
@ -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<string, any> { throw new BaseException('NYI'); }
|
||||
describe(): {[key: string]: any} { throw new BaseException('NYI'); }
|
||||
}
|
||||
|
@ -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<string, any> {
|
||||
describe(): {[key: string]: any} {
|
||||
return {'sampleSize': this._sampleSize, 'regressionSlopeMetric': this._metric};
|
||||
}
|
||||
|
||||
|
@ -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<string, any> { return {'sampleSize': this._sampleSize}; }
|
||||
describe(): {[key: string]: any} { return {'sampleSize': this._sampleSize}; }
|
||||
|
||||
validate(completeSample: MeasureValues[]): MeasureValues[] {
|
||||
if (completeSample.length >= this._sampleSize) {
|
||||
|
@ -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<string, any>): boolean { return true; }
|
||||
supports(capabilities: {[key: string]: any}): boolean { return true; }
|
||||
}
|
||||
|
||||
export class PerfLogFeatures {
|
||||
|
@ -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<StringMap<string, any>>,
|
||||
normalizedEvents: Array<StringMap<string, any>> = 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<string, any>): boolean {
|
||||
supports(capabilities: {[key: string]: any}): boolean {
|
||||
return this._majorChromeVersion != -1 &&
|
||||
StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'chrome');
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeEvent(chromeEvent: StringMap<string, any>, data: StringMap<string, any>):
|
||||
StringMap<string, any> {
|
||||
function normalizeEvent(chromeEvent: {[key: string]: any}, data: {[key: string]: any}):
|
||||
{[key: string]: any} {
|
||||
var ph = chromeEvent['ph'];
|
||||
if (StringWrapper.equals(ph, 'S')) {
|
||||
ph = 'b';
|
||||
|
@ -38,7 +38,7 @@ export class FirefoxDriverExtension extends WebDriverExtension {
|
||||
|
||||
perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true, gc: true}); }
|
||||
|
||||
supports(capabilities: StringMap<string, any>): boolean {
|
||||
supports(capabilities: {[key: string]: any}): boolean {
|
||||
return StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'firefox');
|
||||
}
|
||||
}
|
||||
|
@ -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<string, any>): boolean {
|
||||
supports(capabilities: {[key: string]: any}): boolean {
|
||||
return StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'safari');
|
||||
}
|
||||
}
|
||||
|
@ -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<string> { return PromiseWrapper.resolve(`${this._id}_beginMeasure`); }
|
||||
|
||||
endMeasure(restart: boolean): Promise<StringMap<string, any>> {
|
||||
endMeasure(restart: boolean): Promise<{[key: string]: any}> {
|
||||
var result = {};
|
||||
result[this._id] = {'restart': restart};
|
||||
return PromiseWrapper.resolve(result);
|
||||
}
|
||||
|
||||
describe(): StringMap<string, string> {
|
||||
describe(): {[key: string]: string} {
|
||||
var result = {};
|
||||
result[this._id] = 'describe';
|
||||
return result;
|
||||
|
@ -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<StringMap<string, any>> {
|
||||
reportMeasureValues(values: MeasureValues): Promise<{[key: string]: any}> {
|
||||
return PromiseWrapper.resolve({'id': this._id, 'values': values});
|
||||
}
|
||||
|
||||
reportSample(completeSample: MeasureValues[],
|
||||
validSample: MeasureValues[]): Promise<StringMap<string, any>> {
|
||||
validSample: MeasureValues[]): Promise<{[key: string]: any}> {
|
||||
return PromiseWrapper.resolve(
|
||||
{'id': this._id, 'completeSample': completeSample, 'validSample': validSample});
|
||||
}
|
||||
|
@ -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<string, any>): boolean {
|
||||
supports(capabilities: {[key: string]: any}): boolean {
|
||||
return StringWrapper.equals(capabilities['browser'], this.id);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user