New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FormGroup.reset() input typings are incorrect #55577
Comments
@JeanMeche Can i start be working on this issue? |
This looks like a Typescript type error. In Typescript it is helpful to assign types to variables. For example the syntax goes like: We're saying that a variable called The message is saying that Notice how the format of I'm having trouble getting the error message but I'd try the following:
|
It seems the docs are giving the wrong direction here. Because the type of override reset(
value: ɵTypedOrUntyped<
TControl,
ɵFormGroupValue<TControl>,
any
> = {} as unknown as ɵFormGroupValue<TControl>,
options: {onlySelf?: boolean; emitEvent?: boolean} = {},
): void {
this._forEachChild((control: AbstractControl, name) => {
control.reset(value ? (value as any)[name] : null, {
onlySelf: true,
emitEvent: options.emitEvent,
});
});
// ...
} As you can see it goes through object provided and calls for each control the abstract reset(value?: TValue, options?: Object): void; Meaning the value you passed The best options is: form.reset({
first: 'name',
last: 'last'
});
form.get('first').disable(); |
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
No
Description
The example for resetting a FormGroup that is given here does not match the typing of
FormGroup.reset()
. According to the typings, that{value: 'name', disabled: true}
is invalid.The typing of
FormGroup.reset()
should accept{value: T, disabled: boolean}
for a FormControl because that is how the functionality works.Please provide a link to a minimal reproduction of the bug
https://replit.com/@david-snyder-in/Typing-Issues#src/app/app.component.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: