1

After upgrading my angular version from 4.3.6 to 5.2.4, the AOT compile now throws the error:

ERROR in : Cannot determine the module for class InlineAddComponent in .../src/app/core/component/input/inline-add/inline-add.component.ts! Add InlineAddComponent to the NgModule to fix it.

This Component is declared as part of a module and everything was working flawlessly with AOT compilation prior to the upgrading. I've tried everything I can think of, from changing the module where the component is declared to creating its own module and importing it into the module that was previously declaring it. No matter what, the compiler still complains.

If anyone else has experienced, or resolved this issue, I'd appreciate the insight.

Component:

import {Component, Inject, Input} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
import {ActivatedRoute} from '@angular/router';
import {BaseForm} from '../../form/form/BaseForm';
import {FormDataService, FormDataServiceProvider} from '../../form/form/FormDataService';
import {BaseApi} from '../../../api/BaseApi';

@Component({
    selector: 'inline-add',
    templateUrl: './inline-add.component.html',
    styleUrls: ['./inline-add.component.scss'],
    providers: [
        FormDataServiceProvider
    ]
})
export class InlineAddComponent extends BaseForm {

    @Input() title = 'Entity';
    @Input() formName;

    protected service: BaseApi;

    constructor(
        protected route: ActivatedRoute,
        protected formDataService: FormDataService,
        public dialogRef: MatDialogRef<InlineAddComponent>,
        @Inject(MAT_DIALOG_DATA) public data: {
            form: string,
            title: string,
            service: BaseApi,
        },
    ) {
        super();
        this.title = data.title;
        this.formName = data.form;
        this.service = data.service;
    }

    submit() {
        super.onSubmit(res => {
            this.dialogRef.close(res.data[0]);
        });

    }

    onCancel() {
        this.dialogRef.close(false);
    }

}

Declaring Module:

import { NgModule } from '@angular/core';
import {SharedModule} from '../../../shared/shared.module';
import {InlineAddComponent} from './inline-add/inline-add.component';


@NgModule({
    imports: [
        SharedModule,
    ],
    declarations: [
        InlineAddComponent,
    ],
    exports: [
        InlineAddComponent,
    ],
    entryComponents: [
        InlineAddComponent,
    ]
})
export class FormInputsModule { }
user1119648
  • 531
  • 1
  • 5
  • 16
  • Should we guess what is `InlineAddComponent`, what module imports it and how they all interact with each other? Please post the code – smnbbrv Feb 13 '18 at 18:44
  • It's a general question, it worked on 4.3.6, and doesn't work on 5.2.4 The component itself is irrelevant. This is AOT complaining about unused components, which are not unused. But if it salves your snark, I'll gladly post a useless code snippet. – user1119648 Feb 13 '18 at 18:51
  • Known "issue" : https://github.com/angular/angular/issues/13590 – David Feb 13 '18 at 18:58
  • @David That is the thread requesting a feature that unused components do not break AOT. My component is used, but AOT can't seem to figure that out. – user1119648 Feb 13 '18 at 19:04
  • Sorry I read too fast, I'll delete my comment – David Feb 13 '18 at 19:08
  • No need for all that, I think people's attention should be called to that thread as it relates to this issue, but this issue is not the same thing and is, at least for me, a thousand times more infuriating because I literally AOT compiled this application yesterday under 4.3.6 to make sure that everything was 100% before attempting to upgrade to 5.x. – user1119648 Feb 13 '18 at 19:12
  • Maybe you have an import reference to that component without using it in another file ? https://stackoverflow.com/a/46032806/1160794 – David Feb 13 '18 at 19:58
  • @David The file is only imported/declared in one module. It is also interesting that when I run this on the dev server via ng serve, the component in question works without issue. – user1119648 Feb 13 '18 at 20:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/165093/discussion-between-david-and-user1119648). – David Feb 13 '18 at 20:50
  • 1
    As far as I know, the AOT language is not fully, formally specified anywhere. That means that its behaviour can change without notice because we don't even know how it's supposed to behave exactly in the first place. I requested such a specification and my request was denied and the issue closed and locked within 3 hours. One of the developers was very helpful and gave me access to some semi-private information but it was still in flux and far from complete at the time. – Aluan Haddad Feb 14 '18 at 01:14
  • Hi @user1119648 , I can see in your the chat discussion that somehow adding "./src/**/*" to tsconfig include fixed it for you. I have the exact problem with Angular 7.x now. Can you please elaborate what you did, or give me the link to your gitter? thank you.. – Ren Jan 18 '19 at 01:01
  • @Ren It’s been a long time since I worked on that project and I don’t even remember what he deal was. Sorry. – user1119648 Jan 31 '19 at 19:14

0 Answers0