Skip to content
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

Type FormGroup is not assignable to type AbstractControl #51

Closed
Benny739 opened this issue Oct 20, 2020 · 4 comments
Closed

Type FormGroup is not assignable to type AbstractControl #51

Benny739 opened this issue Oct 20, 2020 · 4 comments

Comments

@Benny739
Copy link

Hi,

in various places I'm getting following error:

Type 'FormGroup<any, any>' is not assignable to type 'AbstractControl'.

It happens for example when I'm using nested FormGroups. The example from the docs also produces this error.

import { FormGroup } from '@ngneat/reactive-forms';

interface Profile {
  firstName: string;
  lastName: string;
  address: {
    street: string;
    city: string;
  };
}

const profileForm = new FormGroup<Profile>({
  firstName: new FormControl(''),
  lastName: new FormControl(''),
  address: new FormGroup({
    street: new FormControl(''),
    city: new FormControl('')
  })
});

Type 'FormGroup<{ street: string; city: string; }, ValidationErrors>' is not assignable to type 'AbstractControl<{ street: string; city: string; }>'.
Types of property 'get' are incompatible.
Type '{ <K1 extends "street" | "city">(path?: [K1] | undefined): AbstractControl<{ street: string; city: string; }[K1]>; <K1 extends "street" | "city", K2 extends keyof { street: string; city: string; }[K1]>(path?: [...] | undefined): AbstractControl<...>; <K1 extends "street" | "city", K2 extends keyof { ...; }[K1], K3 e...' is not assignable to type '(path: string | (string | number)[]) => AbstractControl | null'.
Types of parameters 'path' and 'path' are incompatible.
Type 'string | (string | number)[]' is not assignable to type '[any] | undefined'.
Type 'string' is not assignable to type '[any] | undefined'

@danzrou
Copy link
Collaborator

danzrou commented Oct 20, 2020

Are you using strict mode in TS?

@Benny739
Copy link
Author

Yes.

@danzrou
Copy link
Collaborator

danzrou commented Oct 20, 2020

#26

@danzrou
Copy link
Collaborator

danzrou commented Oct 22, 2020

I am not able to reproduce it on latest version. (which was released today)

Can you check?

@danzrou danzrou closed this as completed Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants