chore(typings): mark underscore methods @internal.

This allows TypeScript to produce an API surface which matches the Dart semantics.
I found these with:
gulp build.js.dev && find dist/js/dev/es5/angular2/src -name "*.d.ts" -exec grep -H -n '^ *_' {} \;

Closes #4638
This commit is contained in:
Alex Eagle
2015-10-09 17:21:25 -07:00
committed by Alex Eagle
parent 95f984615b
commit 867c08ac84
69 changed files with 369 additions and 31 deletions

View File

@ -58,6 +58,7 @@ const controlGroupBinding =
})
export class NgControlGroup extends ControlContainer implements OnInit,
OnDestroy {
/** @internal */
_parent: ControlContainer;
constructor(@Host() @SkipSelf() _parent: ControlContainer) {
super();

View File

@ -80,11 +80,13 @@ const controlNameBinding =
})
export class NgControlName extends NgControl implements OnChanges,
OnDestroy {
/** @internal */
_parent: ControlContainer;
update = new EventEmitter();
model: any;
viewModel: any;
validators: Function[];
/** @internal */
_added = false;
constructor(@Host() @SkipSelf() parent: ControlContainer,

View File

@ -157,10 +157,12 @@ export class NgForm extends ControlContainer implements Form {
return false;
}
/** @internal */
_findContainer(path: string[]): ControlGroup {
path.pop();
return ListWrapper.isEmpty(path) ? this.form : <ControlGroup>this.form.find(path);
}
/** @internal */
_later(fn): void { PromiseWrapper.then(PromiseWrapper.resolve(null), fn, (_) => {}); }
}

View File

@ -72,6 +72,7 @@ const formControlBinding =
export class NgFormControl extends NgControl implements OnChanges {
form: Control;
update = new EventEmitter();
/** @internal */
_added = false;
model: any;
viewModel: any;

View File

@ -140,6 +140,7 @@ export class NgFormModel extends ControlContainer implements Form,
return false;
}
/** @internal */
_updateDomValue() {
this.directives.forEach(dir => {
var ctrl: any = this.form.find(dir.path);

View File

@ -41,7 +41,9 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
exportAs: 'form'
})
export class NgModel extends NgControl implements OnChanges {
/** @internal */
_control = new Control();
/** @internal */
_added = false;
update = new EventEmitter();
model: any;

View File

@ -96,6 +96,7 @@ export class FormBuilder {
}
}
/** @internal */
_reduceControls(controlsConfig: any): {[key: string]: modelModule.AbstractControl} {
var controls: {[key: string]: modelModule.AbstractControl} = {};
StringMapWrapper.forEach(controlsConfig, (controlConfig, controlName) => {
@ -104,6 +105,7 @@ export class FormBuilder {
return controls;
}
/** @internal */
_createControl(controlConfig: any): modelModule.AbstractControl {
if (controlConfig instanceof modelModule.Control ||
controlConfig instanceof modelModule.ControlGroup ||

View File

@ -41,13 +41,19 @@ function _find(control: AbstractControl, path: Array<string | number>| string) {
* Omitting from external API doc as this is really an abstract internal concept.
*/
export class AbstractControl {
/** @internal */
_value: any;
/** @internal */
_status: string;
/** @internal */
_errors: {[key: string]: any};
/** @internal */
_pristine: boolean = true;
/** @internal */
_touched: boolean = false;
/** @internal */
_parent: ControlGroup | ControlArray;
/** @internal */
_valueChanges: EventEmitter;
constructor(public validator: Function) {}
@ -128,6 +134,7 @@ export class AbstractControl {
return isPresent(this.getError(errorCode, path));
}
/** @internal */
_updateValue(): void {}
}
@ -148,6 +155,7 @@ export class AbstractControl {
* ### Example ([live demo](http://plnkr.co/edit/23DESOpbNnBpBHZt1BR4?p=preview))
*/
export class Control extends AbstractControl {
/** @internal */
_onChange: Function;
constructor(value: any = null, validator: Function = Validators.nullValidator) {
@ -234,12 +242,15 @@ export class ControlGroup extends AbstractControl {
return c && this._included(controlName);
}
/** @internal */
_setParentForControls() {
StringMapWrapper.forEach(this.controls, (control, name) => { control.setParent(this); });
}
/** @internal */
_updateValue() { this._value = this._reduceValue(); }
/** @internal */
_reduceValue() {
return this._reduceChildren({}, (acc, control, name) => {
acc[name] = control.value;
@ -247,6 +258,7 @@ export class ControlGroup extends AbstractControl {
});
}
/** @internal */
_reduceChildren(initValue: any, fn: Function) {
var res = initValue;
StringMapWrapper.forEach(this.controls, (control, name) => {
@ -257,6 +269,7 @@ export class ControlGroup extends AbstractControl {
return res;
}
/** @internal */
_included(controlName: string): boolean {
var isOptional = StringMapWrapper.contains(this._optionals, controlName);
return !isOptional || StringMapWrapper.get(this._optionals, controlName);
@ -331,8 +344,10 @@ export class ControlArray extends AbstractControl {
*/
get length(): number { return this.controls.length; }
/** @internal */
_updateValue(): void { this._value = this.controls.map((control) => control.value); }
/** @internal */
_setParentForControls(): void {
this.controls.forEach((control) => { control.setParent(this); });
}