htmlangularvalidationcommand-line-interfaceangular2-aot

Unable to use HTML form validators for Angular AoT - "property 'required does not exist"


I'm attempting to build an Angular 2 project, using angular-cli with the --prod and --aot arguments. The build is failing with the following error:

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

In my HTML, I'm using HTML validation on some of my inputs (required, pattern attributes).

Using JIT compilation, these work as expected. It is only during AoT compilation that the errors occur.

Has anyone seen this before? I was hoping not to have to resort to defining all of my forms using the ReactiveForms method and using the Angular Validators, unless there's no way around it.


Solution

  • The following are some things that will make AoT compile fail.