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

build project with ivy enabled #14

Open
SourceCodeBot opened this issue Aug 15, 2019 · 6 comments
Open

build project with ivy enabled #14

SourceCodeBot opened this issue Aug 15, 2019 · 6 comments

Comments

@SourceCodeBot
Copy link

help wanted, question

using ivy enabled and form typed
export type RecipeForm = Omit<Recipe, 'id'>;
cause in prod build the following error

ERROR in .../component.html(1,7): Type 'FormGroup<Pick<Recipe, "title" | "parts" | "description" | "duration">>' is missing the following properties from type 'FormGroup': _parent, _asyncValidationSubscription, _updateAncestors, _setInitialStatus, and 4 more.

source line is <form [formGroup]="form">

and the necessary code parts are
public form: FormGroup<RecipeForm>;
and
this.form = new FormGroup({ title: new FormControl<string>('', [ Validators.required, Validators.maxLength(100) ]), description: new FormControl<string>('', Validators.required), duration: new FormControl(null) });

is this error in ivy or this project?
without ivy enabled in tsconfig.app.json it build fine.

@SourceCodeBot
Copy link
Author

SourceCodeBot commented Aug 15, 2019

see package.json and yarn.lock
gist

@no0x9d
Copy link
Owner

no0x9d commented Oct 29, 2019

First off, sorry for the late reply.
I have an idea what causes this error. There are private fields on the Angular classes I didn't include in my type definitions. It seems that Ivy has stronger type checking in Templates than the current compiler and are not longer compatible.
I will try to find a solution for this problem

@no0x9d
Copy link
Owner

no0x9d commented Nov 4, 2019

I did some research on this problem. It seems that Ivy has stronger compile time type checking than the aot build before. Because I don't inherite from the Angular classes my types are not compatible. For more information a see the TS documentation
The main problem here is, that I can't inherite from two classes, eg. my FormControl has to inherite from my AbstractControl<> and from Angulars FormControl.
I'll try to get a inheritance hierarchy without breaking changes or loosing type safety, or finding another way.

@SourceCodeBot
Copy link
Author

dear @no0x9d,
thanks for reply and researching.
I hope you could find a good way to solve this problem.
I'll also try to find a solution

@RohanHart
Copy link

In Angular 9-rc.1 this error only occurs in the strictest typecheck mode, ie., with strictTemplates: true

@RohanHart
Copy link

Potential fix in #26 or more radically #27

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

3 participants