I was trying to subclass Angular's FormControl
when I ran into this error : TS2510 : Base constructors must all have the same return type
import { FormControl } from '@angular/forms';
export class Control<T = any> extends FormControl<T> {}
I suspect ɵFormControlCtor to be at fault.
Edit:
Extending the AbstractControl
does not trigger this error:
import { AbstractControl } from '@angular/forms';
export class Control<T> extends AbstractControl<T> {
patchValue(): void { }
reset(): void { }
setValue(): void { }
}
Long story short,
FormControl
is currently defined as a class expression of type ɵFormControlCtor
with an interface with multiple overloads for the constructor, not a proper class.
As pointed by Andrew Allen, this is due to TS's inability to have constructor overloads with different types. (#35387).