refactor(forms): ensure compatibility with noImplicitOverride (#42512)
Adds the `override` keyword to the `forms` sources to ensure compatibility with `noImplicitOverride`. PR Close #42512
This commit is contained in:
parent
c13ccc37cf
commit
01e869a45b
|
@ -60,7 +60,7 @@ export class AbstractFormGroupDirective extends ControlContainer implements OnIn
|
|||
* @description
|
||||
* The path to this group from the top-level directive.
|
||||
*/
|
||||
get path(): string[] {
|
||||
override get path(): string[] {
|
||||
return controlPath(this.name == null ? this.name : this.name.toString(), this._parent);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ export class AbstractFormGroupDirective extends ControlContainer implements OnIn
|
|||
* @description
|
||||
* The top-level directive for this group if present, otherwise null.
|
||||
*/
|
||||
get formDirective(): Form|null {
|
||||
override get formDirective(): Form|null {
|
||||
return this._parent ? this._parent.formDirective : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ export abstract class ControlContainer extends AbstractControlDirective {
|
|||
* @description
|
||||
* The path to this group.
|
||||
*/
|
||||
get path(): string[]|null {
|
||||
override get path(): string[]|null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ export class NgForm extends ControlContainer implements Form, AfterViewInit {
|
|||
* @description
|
||||
* The directive instance.
|
||||
*/
|
||||
get formDirective(): Form {
|
||||
override get formDirective(): Form {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ export class NgForm extends ControlContainer implements Form, AfterViewInit {
|
|||
* Returns an array representing the path to this group. Because this directive
|
||||
* always lives at the top level of a form, it is always an empty array.
|
||||
*/
|
||||
get path(): string[] {
|
||||
override get path(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ export class NgModel extends NgControl implements OnChanges, OnDestroy {
|
|||
* uses this name as a key to retrieve this control's value.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input() name!: string;
|
||||
@Input() override name!: string;
|
||||
|
||||
/**
|
||||
* @description
|
||||
|
@ -240,7 +240,7 @@ export class NgModel extends NgControl implements OnChanges, OnDestroy {
|
|||
* Returns an array that represents the path from the top-level form to this control.
|
||||
* Each index is the string name of the control on that level.
|
||||
*/
|
||||
get path(): string[] {
|
||||
override get path(): string[] {
|
||||
return this._parent ? controlPath(this.name, this._parent) : [this.name];
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ export class NgModelGroup extends AbstractFormGroupDirective implements OnInit,
|
|||
* to a key in the parent `NgForm`.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input('ngModelGroup') name!: string;
|
||||
@Input('ngModelGroup') override name!: string;
|
||||
|
||||
constructor(
|
||||
@Host() @SkipSelf() parent: ControlContainer,
|
||||
|
@ -69,7 +69,7 @@ export class NgModelGroup extends AbstractFormGroupDirective implements OnInit,
|
|||
}
|
||||
|
||||
/** @internal */
|
||||
_checkParentType(): void {
|
||||
override _checkParentType(): void {
|
||||
if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm) &&
|
||||
(typeof ngDevMode === 'undefined' || ngDevMode)) {
|
||||
TemplateDrivenErrors.modelGroupParentException();
|
||||
|
|
|
@ -62,7 +62,7 @@ export class NumberValueAccessor extends BuiltInControlValueAccessor implements
|
|||
* Registers a function called when the control value changes.
|
||||
* @nodoc
|
||||
*/
|
||||
registerOnChange(fn: (_: number|null) => void): void {
|
||||
override registerOnChange(fn: (_: number|null) => void): void {
|
||||
this.onChange = (value) => {
|
||||
fn(value == '' ? null : parseFloat(value));
|
||||
};
|
||||
|
|
|
@ -129,7 +129,7 @@ export class RadioControlValueAccessor extends BuiltInControlValueAccessor imple
|
|||
* `BaseControlValueAccessor` class.
|
||||
* @nodoc
|
||||
*/
|
||||
onChange = () => {};
|
||||
override onChange = () => {};
|
||||
|
||||
/**
|
||||
* @description
|
||||
|
@ -183,7 +183,7 @@ export class RadioControlValueAccessor extends BuiltInControlValueAccessor imple
|
|||
* Registers a function called when the control value changes.
|
||||
* @nodoc
|
||||
*/
|
||||
registerOnChange(fn: (_: any) => {}): void {
|
||||
override registerOnChange(fn: (_: any) => {}): void {
|
||||
this._fn = fn;
|
||||
this.onChange = () => {
|
||||
fn(this.value);
|
||||
|
|
|
@ -64,7 +64,7 @@ export class RangeValueAccessor extends BuiltInControlValueAccessor implements
|
|||
* Registers a function called when the control value changes.
|
||||
* @nodoc
|
||||
*/
|
||||
registerOnChange(fn: (_: number|null) => void): void {
|
||||
override registerOnChange(fn: (_: number|null) => void): void {
|
||||
this.onChange = (value) => {
|
||||
fn(value == '' ? null : parseFloat(value));
|
||||
};
|
||||
|
|
|
@ -149,7 +149,7 @@ export class FormControlDirective extends NgControl implements OnChanges, OnDest
|
|||
* Returns an array that represents the path from the top-level form to this control.
|
||||
* Each index is the string name of the control on that level.
|
||||
*/
|
||||
get path(): string[] {
|
||||
override get path(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy {
|
|||
* to indices when iterating over controls in a `FormArray`.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input('formControlName') name!: string|number|null;
|
||||
@Input('formControlName') override name!: string|number|null;
|
||||
|
||||
/**
|
||||
* @description
|
||||
|
@ -176,7 +176,7 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy {
|
|||
* Returns an array that represents the path from the top-level form to this control.
|
||||
* Each index is the string name of the control on that level.
|
||||
*/
|
||||
get path(): string[] {
|
||||
override get path(): string[] {
|
||||
return controlPath(this.name == null ? this.name : this.name.toString(), this._parent!);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ export class FormGroupDirective extends ControlContainer implements Form, OnChan
|
|||
* @description
|
||||
* Returns this directive's instance.
|
||||
*/
|
||||
get formDirective(): Form {
|
||||
override get formDirective(): Form {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ export class FormGroupDirective extends ControlContainer implements Form, OnChan
|
|||
* Returns an array representing the path to this group. Because this directive
|
||||
* always lives at the top level of a form, it always an empty array.
|
||||
*/
|
||||
get path(): string[] {
|
||||
override get path(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ export class FormGroupName extends AbstractFormGroupDirective implements OnInit,
|
|||
* to indices when iterating over groups in a `FormArray`.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input('formGroupName') name!: string|number|null;
|
||||
@Input('formGroupName') override name!: string|number|null;
|
||||
|
||||
constructor(
|
||||
@Optional() @Host() @SkipSelf() parent: ControlContainer,
|
||||
|
@ -96,7 +96,7 @@ export class FormGroupName extends AbstractFormGroupDirective implements OnInit,
|
|||
}
|
||||
|
||||
/** @internal */
|
||||
_checkParentType(): void {
|
||||
override _checkParentType(): void {
|
||||
if (_hasInvalidParent(this._parent) && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
||||
ReactiveErrors.groupParentException();
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ export class FormArrayName extends ControlContainer implements OnInit, OnDestroy
|
|||
* to indices when iterating over arrays in a `FormArray`.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input('formArrayName') name!: string|number|null;
|
||||
@Input('formArrayName') override name!: string|number|null;
|
||||
|
||||
constructor(
|
||||
@Optional() @Host() @SkipSelf() parent: ControlContainer,
|
||||
|
@ -192,7 +192,7 @@ export class FormArrayName extends ControlContainer implements OnInit, OnDestroy
|
|||
* @description
|
||||
* The top-level directive for this group if present, otherwise null.
|
||||
*/
|
||||
get formDirective(): FormGroupDirective|null {
|
||||
override get formDirective(): FormGroupDirective|null {
|
||||
return this._parent ? <FormGroupDirective>this._parent.formDirective : null;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ export class FormArrayName extends ControlContainer implements OnInit, OnDestroy
|
|||
* Returns an array that represents the path from the top-level form to this control.
|
||||
* Each index is the string name of the control on that level.
|
||||
*/
|
||||
get path(): string[] {
|
||||
override get path(): string[] {
|
||||
return controlPath(this.name == null ? this.name : this.name.toString(), this._parent);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ export class SelectControlValueAccessor extends BuiltInControlValueAccessor impl
|
|||
* Registers a function called when the control value changes.
|
||||
* @nodoc
|
||||
*/
|
||||
registerOnChange(fn: (value: any) => any): void {
|
||||
override registerOnChange(fn: (value: any) => any): void {
|
||||
this.onChange = (valueString: string) => {
|
||||
this.value = this._getOptionValue(valueString);
|
||||
fn(this.value);
|
||||
|
|
|
@ -136,7 +136,7 @@ export class SelectMultipleControlValueAccessor extends BuiltInControlValueAcces
|
|||
* and writes an array of the selected options.
|
||||
* @nodoc
|
||||
*/
|
||||
registerOnChange(fn: (value: any) => any): void {
|
||||
override registerOnChange(fn: (value: any) => any): void {
|
||||
this.onChange = (_: any) => {
|
||||
const selected: Array<any> = [];
|
||||
if (_.selectedOptions !== undefined) {
|
||||
|
|
|
@ -410,7 +410,7 @@ export class CheckboxRequiredValidator extends RequiredValidator {
|
|||
* Returns the validation result if enabled, otherwise null.
|
||||
* @nodoc
|
||||
*/
|
||||
validate(control: AbstractControl): ValidationErrors|null {
|
||||
override validate(control: AbstractControl): ValidationErrors|null {
|
||||
return this.required ? requiredTrueValidator(control) : null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue