question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property … does not exist on type ‘{ [key: string]: AbstractControl; }’

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior When compiling a form with AoT I’ll get:

Property 'email' does not exist on type '{ [key: string]: AbstractControl; }'.

First I thought it was a bug in Ionic which reported. They stated that it was a code issue: https://github.com/driftyco/ionic-app-scripts/issues/100#issuecomment-251790964, but it looks like it has something to do with AoT.

More people reported this error see: https://forum.ionicframework.com/t/property-does-not-exist-on-type-key-string-abstractcontrol/65783 and https://forum.ionicframework.com/t/deploy-to-android-phone-show-white-page-after-upgrade-to-2-0-0-rc-0/66283/5

Expected behavior When you create a variable to store a FormGroup with the type FormGroup there shouldn’t be an error:

Minimal reproduction of the problem with instructions

recoverPasswordForm: FormGroup;

constructor(

    fb: FormBuilder) {

    this.recoverPasswordForm = new FormGroup({
        email: new FormControl([navParams.get('username') || '', Validators.compose([Validators.required, ValidatorService.email])),
    });

}

changing recoverPasswordForm: FormGroup; into recoverPasswordForm = null; solves the problem

What is the motivation / use case for changing the behavior? This is used for forms

Please tell us about your environment: OSX, Vscode, npm, Ionic2 RC0

  • Angular version: 2.0.X

  • Browser: Chrome / All

  • Language: Typescript

  • Node (for AoT issues): node --version = v6.7.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
DzmitryShylovichcommented, Oct 9, 2016

Replace <form-error [control]="recoverPasswordForm.controls.email" error="required">{{ 'errors.fieldRequired' | translate }}</form-error> with <form-error [control]="recoverPasswordForm.get('email')" error="required">{{ 'errors.fieldRequired' | translate }}</form-error>

Also see https://github.com/qdouble/angular-webpack2-starter#aot--donts

0reactions
angular-automatic-lock-bot[bot]commented, Sep 12, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property … does not exist on type '{ [key: string]: AbstractControl
It turned out the problem is caused when this.recoverPasswordForm is defined as: recoverPasswordForm: FormGroup. instead when I use.
Read more >
Property ... does not exist on type '{ [key: string]: AbstractControl
I am having a form defined as the code below. ionic serve does fine, However when I compile my app using ionic run...
Read more >
AbstractControl - Angular
An object containing any errors generated by failing validation, or null if there are no errors. pristine: boolean, Read-Only. A control is pristine...
Read more >
Strictly typed forms in Angular | Ninja Squad
setValue and patchValue are also type-safe: you can't set a number on a FormControl<string> for example. get(). The get(key) method is also more ......
Read more >
property 'length' does not exist on type object angular 6
2. Basically angular does not know which type is returned by your http call, therefore it autocasts it into an object, which has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found