Skip to content

Commit 22d8f73

Browse files
Jason ChoiIgorMinar
Jason Choi
authored andcommitted
test: add public api golden files
Includes a few style fixes on "* as foo" imports.
1 parent 249a6bd commit 22d8f73

File tree

25 files changed

+3658
-67
lines changed

25 files changed

+3658
-67
lines changed

gulpfile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ const entrypoints = [
4343
'dist/packages-dist/platform-server/index.d.ts',
4444
'dist/packages-dist/platform-server/testing.d.ts',
4545
'dist/packages-dist/http/index.d.ts',
46-
'dist/packages-dist/http/testing.d.ts'
46+
'dist/packages-dist/http/testing.d.ts',
47+
'dist/packages-dist/forms/index.d.ts',
48+
'dist/packages-dist/router/index.d.ts'
4749
];
4850
const publicApiDir = 'tools/public_api_guard';
4951
const publicApiArgs = [

modules/@angular/common/src/forms-deprecated/form_builder.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {StringMapWrapper} from '../facade/collection';
1212
import {isArray, isPresent} from '../facade/lang';
1313

1414
import {AsyncValidatorFn, ValidatorFn} from './directives/validators';
15-
import * as modelModule from './model';
15+
import {AbstractControl, Control, ControlArray, ControlGroup} from './model';
1616

1717

1818

@@ -67,22 +67,21 @@ export class FormBuilder {
6767
*
6868
* See the {@link ControlGroup} constructor for more details.
6969
*/
70-
group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null):
71-
modelModule.ControlGroup {
70+
group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null): ControlGroup {
7271
var controls = this._reduceControls(controlsConfig);
7372
var optionals = <{[key: string]: boolean}>(
7473
isPresent(extra) ? StringMapWrapper.get(extra, 'optionals') : null);
7574
var validator: ValidatorFn = isPresent(extra) ? StringMapWrapper.get(extra, 'validator') : null;
7675
var asyncValidator: AsyncValidatorFn =
7776
isPresent(extra) ? StringMapWrapper.get(extra, 'asyncValidator') : null;
78-
return new modelModule.ControlGroup(controls, optionals, validator, asyncValidator);
77+
return new ControlGroup(controls, optionals, validator, asyncValidator);
7978
}
8079
/**
8180
* Construct a new {@link Control} with the given `value`,`validator`, and `asyncValidator`.
8281
*/
8382
control(value: Object, validator: ValidatorFn = null, asyncValidator: AsyncValidatorFn = null):
84-
modelModule.Control {
85-
return new modelModule.Control(value, validator, asyncValidator);
83+
Control {
84+
return new Control(value, validator, asyncValidator);
8685
}
8786

8887
/**
@@ -91,26 +90,24 @@ export class FormBuilder {
9190
*/
9291
array(
9392
controlsConfig: any[], validator: ValidatorFn = null,
94-
asyncValidator: AsyncValidatorFn = null): modelModule.ControlArray {
93+
asyncValidator: AsyncValidatorFn = null): ControlArray {
9594
var controls = controlsConfig.map(c => this._createControl(c));
96-
return new modelModule.ControlArray(controls, validator, asyncValidator);
95+
return new ControlArray(controls, validator, asyncValidator);
9796
}
9897

9998
/** @internal */
100-
_reduceControls(controlsConfig: {[k: string]: any}):
101-
{[key: string]: modelModule.AbstractControl} {
102-
var controls: {[key: string]: modelModule.AbstractControl} = {};
99+
_reduceControls(controlsConfig: {[k: string]: any}): {[key: string]: AbstractControl} {
100+
var controls: {[key: string]: AbstractControl} = {};
103101
StringMapWrapper.forEach(controlsConfig, (controlConfig: any, controlName: string) => {
104102
controls[controlName] = this._createControl(controlConfig);
105103
});
106104
return controls;
107105
}
108106

109107
/** @internal */
110-
_createControl(controlConfig: any): modelModule.AbstractControl {
111-
if (controlConfig instanceof modelModule.Control ||
112-
controlConfig instanceof modelModule.ControlGroup ||
113-
controlConfig instanceof modelModule.ControlArray) {
108+
_createControl(controlConfig: any): AbstractControl {
109+
if (controlConfig instanceof Control || controlConfig instanceof ControlGroup ||
110+
controlConfig instanceof ControlArray) {
114111
return controlConfig;
115112

116113
} else if (isArray(controlConfig)) {

modules/@angular/common/src/forms-deprecated/validators.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {StringMapWrapper} from '../facade/collection';
1212
import {isBlank, isPresent, isPromise, isString} from '../facade/lang';
1313
import {PromiseWrapper} from '../facade/promise';
1414
import {AsyncValidatorFn, ValidatorFn} from './directives/validators';
15-
import * as modelModule from './model';
15+
import {AbstractControl} from './model';
1616

1717
/**
1818
* Providers for validators to be used for {@link Control}s in a form.
@@ -57,7 +57,7 @@ export class Validators {
5757
/**
5858
* Validator that requires controls to have a non-empty value.
5959
*/
60-
static required(control: modelModule.AbstractControl): {[key: string]: boolean} {
60+
static required(control: AbstractControl): {[key: string]: boolean} {
6161
return isBlank(control.value) || (isString(control.value) && control.value == '') ?
6262
{'required': true} :
6363
null;
@@ -67,7 +67,7 @@ export class Validators {
6767
* Validator that requires controls to have a value of a minimum length.
6868
*/
6969
static minLength(minLength: number): ValidatorFn {
70-
return (control: modelModule.AbstractControl): {[key: string]: any} => {
70+
return (control: AbstractControl): {[key: string]: any} => {
7171
if (isPresent(Validators.required(control))) return null;
7272
var v: string = control.value;
7373
return v.length < minLength ?
@@ -80,7 +80,7 @@ export class Validators {
8080
* Validator that requires controls to have a value of a maximum length.
8181
*/
8282
static maxLength(maxLength: number): ValidatorFn {
83-
return (control: modelModule.AbstractControl): {[key: string]: any} => {
83+
return (control: AbstractControl): {[key: string]: any} => {
8484
if (isPresent(Validators.required(control))) return null;
8585
var v: string = control.value;
8686
return v.length > maxLength ?
@@ -93,7 +93,7 @@ export class Validators {
9393
* Validator that requires a control to match a regex to its value.
9494
*/
9595
static pattern(pattern: string): ValidatorFn {
96-
return (control: modelModule.AbstractControl): {[key: string]: any} => {
96+
return (control: AbstractControl): {[key: string]: any} => {
9797
if (isPresent(Validators.required(control))) return null;
9898
let regex = new RegExp(`^${pattern}$`);
9999
let v: string = control.value;
@@ -105,7 +105,7 @@ export class Validators {
105105
/**
106106
* No-op validator.
107107
*/
108-
static nullValidator(c: modelModule.AbstractControl): {[key: string]: boolean} { return null; }
108+
static nullValidator(c: AbstractControl): {[key: string]: boolean} { return null; }
109109

110110
/**
111111
* Compose multiple validators into a single function that returns the union
@@ -116,7 +116,7 @@ export class Validators {
116116
var presentValidators = validators.filter(isPresent);
117117
if (presentValidators.length == 0) return null;
118118

119-
return function(control: modelModule.AbstractControl) {
119+
return function(control: AbstractControl) {
120120
return _mergeErrors(_executeValidators(control, presentValidators));
121121
};
122122
}
@@ -126,7 +126,7 @@ export class Validators {
126126
var presentValidators = validators.filter(isPresent);
127127
if (presentValidators.length == 0) return null;
128128

129-
return function(control: modelModule.AbstractControl) {
129+
return function(control: AbstractControl) {
130130
let promises = _executeAsyncValidators(control, presentValidators).map(_convertToPromise);
131131
return PromiseWrapper.all(promises).then(_mergeErrors);
132132
};
@@ -137,13 +137,11 @@ function _convertToPromise(obj: any): Promise<any> {
137137
return isPromise(obj) ? obj : ObservableWrapper.toPromise(obj);
138138
}
139139

140-
function _executeValidators(
141-
control: modelModule.AbstractControl, validators: ValidatorFn[]): any[] {
140+
function _executeValidators(control: AbstractControl, validators: ValidatorFn[]): any[] {
142141
return validators.map(v => v(control));
143142
}
144143

145-
function _executeAsyncValidators(
146-
control: modelModule.AbstractControl, validators: AsyncValidatorFn[]): any[] {
144+
function _executeAsyncValidators(control: AbstractControl, validators: AsyncValidatorFn[]): any[] {
147145
return validators.map(v => v(control));
148146
}
149147

modules/@angular/core/src/profile/profile.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import * as impl from './wtf_impl';
9+
import {WtfScopeFn, createScope, detectWTF, endTimeRange, leave, startTimeRange} from './wtf_impl';
1010

1111
export {WtfScopeFn} from './wtf_impl';
1212

@@ -16,7 +16,7 @@ export {WtfScopeFn} from './wtf_impl';
1616
/**
1717
* True if WTF is enabled.
1818
*/
19-
export var wtfEnabled = impl.detectWTF();
19+
export var wtfEnabled = detectWTF();
2020

2121
function noopScope(arg0?: any, arg1?: any): any {
2222
return null;
@@ -52,8 +52,8 @@ function noopScope(arg0?: any, arg1?: any): any {
5252
*
5353
* @experimental
5454
*/
55-
export var wtfCreateScope: (signature: string, flags?: any) => impl.WtfScopeFn =
56-
wtfEnabled ? impl.createScope : (signature: string, flags?: any) => noopScope;
55+
export var wtfCreateScope: (signature: string, flags?: any) => WtfScopeFn =
56+
wtfEnabled ? createScope : (signature: string, flags?: any) => noopScope;
5757

5858
/**
5959
* Used to mark end of Scope.
@@ -65,7 +65,7 @@ export var wtfCreateScope: (signature: string, flags?: any) => impl.WtfScopeFn =
6565
* @experimental
6666
*/
6767
export var wtfLeave: <T>(scope: any, returnValue?: T) => T =
68-
wtfEnabled ? impl.leave : (s: any, r?: any) => r;
68+
wtfEnabled ? leave : (s: any, r?: any) => r;
6969

7070
/**
7171
* Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
@@ -81,13 +81,12 @@ export var wtfLeave: <T>(scope: any, returnValue?: T) => T =
8181
* @experimental
8282
*/
8383
export var wtfStartTimeRange: (rangeType: string, action: string) => any =
84-
wtfEnabled ? impl.startTimeRange : (rangeType: string, action: string) => null;
84+
wtfEnabled ? startTimeRange : (rangeType: string, action: string) => null;
8585

8686
/**
8787
* Ends a async time range operation.
8888
* [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
8989
* enabled.
9090
* @experimental
9191
*/
92-
export var wtfEndTimeRange: (range: any) => void =
93-
wtfEnabled ? impl.endTimeRange : (r: any) => null;
92+
export var wtfEndTimeRange: (range: any) => void = wtfEnabled ? endTimeRange : (r: any) => null;

modules/@angular/forms/src/form_builder.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {Injectable} from '@angular/core';
1111
import {AsyncValidatorFn, ValidatorFn} from './directives/validators';
1212
import {StringMapWrapper} from './facade/collection';
1313
import {isArray, isPresent} from './facade/lang';
14-
import * as modelModule from './model';
14+
import {AbstractControl, FormArray, FormControl, FormGroup} from './model';
1515

1616

1717

@@ -63,23 +63,22 @@ export class FormBuilder {
6363
*
6464
* See the {@link FormGroup} constructor for more details.
6565
*/
66-
group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null):
67-
modelModule.FormGroup {
66+
group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null): FormGroup {
6867
var controls = this._reduceControls(controlsConfig);
6968
var optionals = <{[key: string]: boolean}>(
7069
isPresent(extra) ? StringMapWrapper.get(extra, 'optionals') : null);
7170
var validator: ValidatorFn = isPresent(extra) ? StringMapWrapper.get(extra, 'validator') : null;
7271
var asyncValidator: AsyncValidatorFn =
7372
isPresent(extra) ? StringMapWrapper.get(extra, 'asyncValidator') : null;
74-
return new modelModule.FormGroup(controls, optionals, validator, asyncValidator);
73+
return new FormGroup(controls, optionals, validator, asyncValidator);
7574
}
7675
/**
7776
* Construct a new {@link FormControl} with the given `value`,`validator`, and `asyncValidator`.
7877
*/
7978
control(
8079
value: Object, validator: ValidatorFn|ValidatorFn[] = null,
81-
asyncValidator: AsyncValidatorFn|AsyncValidatorFn[] = null): modelModule.FormControl {
82-
return new modelModule.FormControl(value, validator, asyncValidator);
80+
asyncValidator: AsyncValidatorFn|AsyncValidatorFn[] = null): FormControl {
81+
return new FormControl(value, validator, asyncValidator);
8382
}
8483

8584
/**
@@ -88,26 +87,24 @@ export class FormBuilder {
8887
*/
8988
array(
9089
controlsConfig: any[], validator: ValidatorFn = null,
91-
asyncValidator: AsyncValidatorFn = null): modelModule.FormArray {
90+
asyncValidator: AsyncValidatorFn = null): FormArray {
9291
var controls = controlsConfig.map(c => this._createControl(c));
93-
return new modelModule.FormArray(controls, validator, asyncValidator);
92+
return new FormArray(controls, validator, asyncValidator);
9493
}
9594

9695
/** @internal */
97-
_reduceControls(controlsConfig: {[k: string]: any}):
98-
{[key: string]: modelModule.AbstractControl} {
99-
var controls: {[key: string]: modelModule.AbstractControl} = {};
96+
_reduceControls(controlsConfig: {[k: string]: any}): {[key: string]: AbstractControl} {
97+
var controls: {[key: string]: AbstractControl} = {};
10098
StringMapWrapper.forEach(controlsConfig, (controlConfig: any, controlName: string) => {
10199
controls[controlName] = this._createControl(controlConfig);
102100
});
103101
return controls;
104102
}
105103

106104
/** @internal */
107-
_createControl(controlConfig: any): modelModule.AbstractControl {
108-
if (controlConfig instanceof modelModule.FormControl ||
109-
controlConfig instanceof modelModule.FormGroup ||
110-
controlConfig instanceof modelModule.FormArray) {
105+
_createControl(controlConfig: any): AbstractControl {
106+
if (controlConfig instanceof FormControl || controlConfig instanceof FormGroup ||
107+
controlConfig instanceof FormArray) {
111108
return controlConfig;
112109

113110
} else if (isArray(controlConfig)) {

modules/@angular/forms/src/validators.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {ObservableWrapper} from './facade/async';
1212
import {StringMapWrapper} from './facade/collection';
1313
import {isBlank, isPresent, isPromise, isString} from './facade/lang';
1414
import {PromiseWrapper} from './facade/promise';
15-
import * as modelModule from './model';
15+
import {AbstractControl} from './model';
1616

1717
/**
1818
* Providers for validators to be used for {@link FormControl}s in a form.
@@ -57,7 +57,7 @@ export class Validators {
5757
/**
5858
* Validator that requires controls to have a non-empty value.
5959
*/
60-
static required(control: modelModule.AbstractControl): {[key: string]: boolean} {
60+
static required(control: AbstractControl): {[key: string]: boolean} {
6161
return isBlank(control.value) || (isString(control.value) && control.value == '') ?
6262
{'required': true} :
6363
null;
@@ -67,7 +67,7 @@ export class Validators {
6767
* Validator that requires controls to have a value of a minimum length.
6868
*/
6969
static minLength(minLength: number): ValidatorFn {
70-
return (control: modelModule.AbstractControl): {[key: string]: any} => {
70+
return (control: AbstractControl): {[key: string]: any} => {
7171
if (isPresent(Validators.required(control))) return null;
7272
var v: string = control.value;
7373
return v.length < minLength ?
@@ -80,7 +80,7 @@ export class Validators {
8080
* Validator that requires controls to have a value of a maximum length.
8181
*/
8282
static maxLength(maxLength: number): ValidatorFn {
83-
return (control: modelModule.AbstractControl): {[key: string]: any} => {
83+
return (control: AbstractControl): {[key: string]: any} => {
8484
if (isPresent(Validators.required(control))) return null;
8585
var v: string = control.value;
8686
return v.length > maxLength ?
@@ -93,7 +93,7 @@ export class Validators {
9393
* Validator that requires a control to match a regex to its value.
9494
*/
9595
static pattern(pattern: string): ValidatorFn {
96-
return (control: modelModule.AbstractControl): {[key: string]: any} => {
96+
return (control: AbstractControl): {[key: string]: any} => {
9797
if (isPresent(Validators.required(control))) return null;
9898
let regex = new RegExp(`^${pattern}$`);
9999
let v: string = control.value;
@@ -105,7 +105,7 @@ export class Validators {
105105
/**
106106
* No-op validator.
107107
*/
108-
static nullValidator(c: modelModule.AbstractControl): {[key: string]: boolean} { return null; }
108+
static nullValidator(c: AbstractControl): {[key: string]: boolean} { return null; }
109109

110110
/**
111111
* Compose multiple validators into a single function that returns the union
@@ -116,7 +116,7 @@ export class Validators {
116116
var presentValidators = validators.filter(isPresent);
117117
if (presentValidators.length == 0) return null;
118118

119-
return function(control: modelModule.AbstractControl) {
119+
return function(control: AbstractControl) {
120120
return _mergeErrors(_executeValidators(control, presentValidators));
121121
};
122122
}
@@ -126,7 +126,7 @@ export class Validators {
126126
var presentValidators = validators.filter(isPresent);
127127
if (presentValidators.length == 0) return null;
128128

129-
return function(control: modelModule.AbstractControl) {
129+
return function(control: AbstractControl) {
130130
let promises = _executeAsyncValidators(control, presentValidators).map(_convertToPromise);
131131
return PromiseWrapper.all(promises).then(_mergeErrors);
132132
};
@@ -137,13 +137,11 @@ function _convertToPromise(obj: any): Promise<any> {
137137
return isPromise(obj) ? obj : ObservableWrapper.toPromise(obj);
138138
}
139139

140-
function _executeValidators(
141-
control: modelModule.AbstractControl, validators: ValidatorFn[]): any[] {
140+
function _executeValidators(control: AbstractControl, validators: ValidatorFn[]): any[] {
142141
return validators.map(v => v(control));
143142
}
144143

145-
function _executeAsyncValidators(
146-
control: modelModule.AbstractControl, validators: AsyncValidatorFn[]): any[] {
144+
function _executeAsyncValidators(control: AbstractControl, validators: AsyncValidatorFn[]): any[] {
147145
return validators.map(v => v(control));
148146
}
149147

0 commit comments

Comments
 (0)