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:
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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(_ => {
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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"];
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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] = [];
|
||||
|
Reference in New Issue
Block a user