build(bazel): Turning on strictPropertyInitialization for Angular. (#24572)

All errors for existing fields have been detected and suppressed with a
`!` assertion.

Issue/24571 is tracking proper clean up of those instances.

One-line change required in ivy/compilation.ts, because it appears that
the new syntax causes tsickle emitted node to no longer track their
original sourceFiles.

PR Close #24572
This commit is contained in:
Rado Kirov
2018-06-18 16:38:33 -07:00
committed by Miško Hevery
parent 39c7769c9e
commit c95437f15d
189 changed files with 1273 additions and 632 deletions

View File

@ -24,13 +24,16 @@ import {AsyncValidatorFn, ValidatorFn} from './validators';
*/
export class AbstractFormGroupDirective extends ControlContainer implements OnInit, OnDestroy {
/** @internal */
_parent: ControlContainer;
// TODO(issue/24571): remove '!'.
_parent !: ControlContainer;
/** @internal */
_validators: any[];
// TODO(issue/24571): remove '!'.
_validators !: any[];
/** @internal */
_asyncValidators: any[];
// TODO(issue/24571): remove '!'.
_asyncValidators !: any[];
ngOnInit(): void {
this._checkParentType();

View File

@ -18,7 +18,8 @@ import {Form} from './form_interface';
*
*/
export abstract class ControlContainer extends AbstractControlDirective {
name: string;
// TODO(issue/24571): remove '!'.
name !: string;
/**
* Get the form to which this container belongs.

View File

@ -93,7 +93,8 @@ export class NgForm extends ControlContainer implements Form,
* ```
*
*/
@Input('ngFormOptions') options: {updateOn?: FormHooks};
// TODO(issue/24571): remove '!'.
@Input('ngFormOptions') options !: {updateOn?: FormHooks};
constructor(
@Optional() @Self() @Inject(NG_VALIDATORS) validators: any[],

View File

@ -115,8 +115,10 @@ export class NgModel extends NgControl implements OnChanges,
_registered = false;
viewModel: any;
@Input() name: string;
@Input('disabled') isDisabled: boolean;
// TODO(issue/24571): remove '!'.
@Input() name !: string;
// TODO(issue/24571): remove '!'.
@Input('disabled') isDisabled !: boolean;
@Input('ngModel') model: any;
/**
@ -156,7 +158,9 @@ export class NgModel extends NgControl implements OnChanges,
* ```
*
*/
@Input('ngModelOptions') options: {name?: string, standalone?: boolean, updateOn?: FormHooks};
// TODO(issue/24571): remove '!'.
@Input('ngModelOptions')
options !: {name?: string, standalone?: boolean, updateOn?: FormHooks};
@Output('ngModelChange') update = new EventEmitter();

View File

@ -47,7 +47,8 @@ export const modelGroupProvider: any = {
*/
@Directive({selector: '[ngModelGroup]', providers: [modelGroupProvider], exportAs: 'ngModelGroup'})
export class NgModelGroup extends AbstractFormGroupDirective implements OnInit, OnDestroy {
@Input('ngModelGroup') name: string;
// TODO(issue/24571): remove '!'.
@Input('ngModelGroup') name !: string;
constructor(
@Host() @SkipSelf() parent: ControlContainer,

View File

@ -92,16 +92,21 @@ export class RadioControlRegistry {
export class RadioControlValueAccessor implements ControlValueAccessor,
OnDestroy, OnInit {
/** @internal */
_state: boolean;
// TODO(issue/24571): remove '!'.
_state !: boolean;
/** @internal */
_control: NgControl;
// TODO(issue/24571): remove '!'.
_control !: NgControl;
/** @internal */
_fn: Function;
// TODO(issue/24571): remove '!'.
_fn !: Function;
onChange = () => {};
onTouched = () => {};
@Input() name: string;
@Input() formControlName: string;
// TODO(issue/24571): remove '!'.
@Input() name !: string;
// TODO(issue/24571): remove '!'.
@Input() formControlName !: string;
@Input() value: any;
constructor(

View File

@ -141,7 +141,8 @@ export const formControlBinding: any = {
export class FormControlDirective extends NgControl implements OnChanges {
viewModel: any;
@Input('formControl') form: FormControl;
// TODO(issue/24571): remove '!'.
@Input('formControl') form !: FormControl;
@Input('disabled')
set isDisabled(isDisabled: boolean) { ReactiveErrors.disabledAttrWarning(); }

View File

@ -153,9 +153,11 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy {
private _added = false;
/** @internal */
viewModel: any;
readonly control: FormControl;
// TODO(issue/24571): remove '!'.
readonly control !: FormControl;
@Input('formControlName') name: string;
// TODO(issue/24571): remove '!'.
@Input('formControlName') name !: string;
@Input('disabled')
set isDisabled(isDisabled: boolean) { ReactiveErrors.disabledAttrWarning(); }

View File

@ -68,7 +68,8 @@ export class FormGroupDirective extends ControlContainer implements Form,
OnChanges {
public readonly submitted: boolean = false;
private _oldForm: FormGroup;
// TODO(issue/24571): remove '!'.
private _oldForm !: FormGroup;
directives: FormControlName[] = [];
@Input('formGroup') form: FormGroup = null !;

View File

@ -69,7 +69,8 @@ export const formGroupNameProvider: any = {
*/
@Directive({selector: '[formGroupName]', providers: [formGroupNameProvider]})
export class FormGroupName extends AbstractFormGroupDirective implements OnInit, OnDestroy {
@Input('formGroupName') name: string;
// TODO(issue/24571): remove '!'.
@Input('formGroupName') name !: string;
constructor(
@Optional() @Host() @SkipSelf() parent: ControlContainer,
@ -152,7 +153,8 @@ export class FormArrayName extends ControlContainer implements OnInit, OnDestroy
/** @internal */
_asyncValidators: any[];
@Input('formArrayName') name: string;
// TODO(issue/24571): remove '!'.
@Input('formArrayName') name !: string;
constructor(
@Optional() @Host() @SkipSelf() parent: ControlContainer,

View File

@ -168,7 +168,8 @@ export class SelectControlValueAccessor implements ControlValueAccessor {
*/
@Directive({selector: 'option'})
export class NgSelectOption implements OnDestroy {
id: string;
// TODO(issue/24571): remove '!'.
id !: string;
constructor(
private _element: ElementRef, private _renderer: Renderer2,

View File

@ -35,7 +35,8 @@ interface HTMLOption {
/** Mock interface for HTMLCollection */
abstract class HTMLCollection {
length: number;
// TODO(issue/24571): remove '!'.
length !: number;
abstract item(_: number): HTMLOption;
}
@ -177,7 +178,8 @@ export class SelectMultipleControlValueAccessor implements ControlValueAccessor
*/
@Directive({selector: 'option'})
export class NgSelectMultipleOption implements OnDestroy {
id: string;
// TODO(issue/24571): remove '!'.
id !: string;
/** @internal */
_value: any;

View File

@ -79,8 +79,10 @@ export const CHECKBOX_REQUIRED_VALIDATOR: StaticProvider = {
host: {'[attr.required]': 'required ? "" : null'}
})
export class RequiredValidator implements Validator {
private _required: boolean;
private _onChange: () => void;
// TODO(issue/24571): remove '!'.
private _required !: boolean;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
@Input()
get required(): boolean|string { return this._required; }
@ -150,8 +152,10 @@ export const EMAIL_VALIDATOR: any = {
providers: [EMAIL_VALIDATOR]
})
export class EmailValidator implements Validator {
private _enabled: boolean;
private _onChange: () => void;
// TODO(issue/24571): remove '!'.
private _enabled !: boolean;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
@Input()
set email(value: boolean|string) {
@ -198,10 +202,13 @@ export const MIN_LENGTH_VALIDATOR: any = {
})
export class MinLengthValidator implements Validator,
OnChanges {
private _validator: ValidatorFn;
private _onChange: () => void;
// TODO(issue/24571): remove '!'.
private _validator !: ValidatorFn;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
@Input() minlength: string;
// TODO(issue/24571): remove '!'.
@Input() minlength !: string;
ngOnChanges(changes: SimpleChanges): void {
if ('minlength' in changes) {
@ -248,10 +255,13 @@ export const MAX_LENGTH_VALIDATOR: any = {
})
export class MaxLengthValidator implements Validator,
OnChanges {
private _validator: ValidatorFn;
private _onChange: () => void;
// TODO(issue/24571): remove '!'.
private _validator !: ValidatorFn;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
@Input() maxlength: string;
// TODO(issue/24571): remove '!'.
@Input() maxlength !: string;
ngOnChanges(changes: SimpleChanges): void {
if ('maxlength' in changes) {
@ -299,10 +309,13 @@ export const PATTERN_VALIDATOR: any = {
})
export class PatternValidator implements Validator,
OnChanges {
private _validator: ValidatorFn;
private _onChange: () => void;
// TODO(issue/24571): remove '!'.
private _validator !: ValidatorFn;
// TODO(issue/24571): remove '!'.
private _onChange !: () => void;
@Input() pattern: string|RegExp;
// TODO(issue/24571): remove '!'.
@Input() pattern !: string | RegExp;
ngOnChanges(changes: SimpleChanges): void {
if ('pattern' in changes) {