Error encountered in app.module.ts file of Angular 2 application

My friends and I are working on a big school project, creating a cool web app. Suddenly, I encountered some errors in my app.module.ts file that I haven't seen before. It's strange because they are showing up out of nowhere!

The error:

Error:(32, 11) TS2345: Argument of type '{ imports:typeof BrowserModule[]; exports: typeof SignupFormComponent[];    declarations: (typeof S...' is not assignable to parameter of type 'NgModule'. Types of property 'declarations' are incompatible. Type '(typeof SignupFormComponent | typeof AppComponent | typeof LoaderComponent | typeof MenuComponent...' is not assignable to type '(any[] | Type<any>)[]'. Type 'typeof SignupFormComponent | typeof AppComponent | typeof LoaderComponent | typeof MenuComponent ...' is not assignable to type 'any[] | Type<any>'. Type 'typeof ViewRecipeModalComponent' is not assignable to type 'any[] | Type<any>'. Type 'typeof ViewRecipeModalComponent' is not assignable to type 'Type<any>'. Cannot assign a 'private' constructor type to a 'public' constructor type.  

This is the content of app.module.ts file:

    import {NgModule} from '@angular/core';
    import {BrowserModule} from '@angular/platform-browser';
    import {FormsModule} from '@angular/forms';
    import {HttpModule} from '@angular/http';

    import './rxjs-extensions';
    import {AppComponent} from './app.component';
    import {AppRoutingModule, routedComponents} from './app-routing.module';
    import {Backend} from './shared/services/backend';
    import {MenuComponent} from './menu/menu.component';
    import {PlannerComponent} from './planner/planner.component';
    import {PlannerMenuComponent} from './planner/planner-menu/planner-menu.component';
    import {LoginComponent} from './forms/login/login.component';
    import {SignupFormComponent} from './forms/signup/signup-form.component';
    import {ListsComponent} from './lists/lists.component';
    import {ListEntryControlsComponent} from "./lists/list-entry-controls/list-entry-controls.component";
    import {ListEntryFoodComponent} from './lists/list-entry-food/list-entry-food.component';
    import {ListEntryRecipeComponent} from './lists/list-entry-recipe/list-entry-recipe.component';
    import {ListTopBarComponent} from './lists/list-top-bar/list-top-bar.component';
    import {LoaderComponent} from "./loader/loader.component";
    import {ListErrorComponent} from "./lists/list-error/list-error.component";
    import {RecipeModalComponent} from "./forms/modals/recipe/recipe-modal.component";
    import {CreateFoodModalComponent} from "./forms/modals/create-food/create-food-modal.component";
    import {ViewRecipeModalComponent} from "./forms/modals/view-recipe/view-recipe-modal.component";
    import {Typeahead} from "./forms/typehead/typehead.component";
    import {PlannerWeekGridComponent} from "./planner/planner-week-grid/planner-week-grid.component";
    import {PlannerWeekCellComponent} from "./planner/planner-week-cell/planner-week-cell.component";
    import {DynamicUnitComponent} from "./forms/dynamic-unit/dynamic-unit.component";
    import {TagsEditorComponent} from "./forms/tags-editor/tags-editor.component";
    import {PromoBooksComponent} from "./books/promo-books/promo-books.component";

    @NgModule({
      imports: [
        BrowserModule,
        FormsModule,
        AppRoutingModule,
        HttpModule
      ],
      exports: [
    SignupFormComponent
  ],
  declarations: [
    AppComponent,
    LoaderComponent,
    MenuComponent,
    PlannerMenuComponent,
    PlannerWeekCellComponent,
    PlannerWeekGridComponent,
    PlannerComponent,
    LoginComponent,
    SignupFormComponent,
    ListsComponent,
    ListErrorComponent,
    ListEntryControlsComponent,
    ListEntryFoodComponent,
    ListEntryRecipeComponent,
    ListTopBarComponent,
    ViewRecipeModalComponent,
    RecipeModalComponent,
    CreateFoodModalComponent,
    TagsEditorComponent,
    Typeahead,
    DynamicUnitComponent,
    routedComponents,
    PromoBooksComponent
  ],
  providers: [
    Backend
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

I even tried re-cloning the entire project, but the issue remains. I'm using the latest release of WebStorm. Strangely, I can still run the app using 'npm start', but I can't seem to figure out this error in WebStorm. The error appears right at the start of the ng module.

Answer №1

The reason behind this is due to a private constructor.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue during Firebase production: emptyChildrenSingleton isn't recognized

In my nextjs project, I am using React v18.1.0 and Firebase Realtime Database for handling notifications. The notifications work fine in development mode but fail in the production environment. The errors I encountered are as follows: ReferenceError: empt ...

What is the best way to manually trigger a function($event) in Angular 2?

When working with Angular2, I recently wrote a function that utilizes $event. It works perfectly fine when triggered by a click event from the template class. However, I encountered an issue when trying to manually call this function and pass an event valu ...

What is the best way to insert a triangle shape to the bottom of a div with an opacity level set at 0.2

https://i.stack.imgur.com/sqZpM.png I've been trying to create something similar, but my triangle keeps overlapping with the background in the next section. I've already spent 3 hours on it. Any help would be greatly appreciated. Check out my c ...

Unable to connect to web3 object using typescript and ethereum

Embarking on a fresh project with Angular 2 and TypeScript, I kicked things off by using the command: ng new myProject Next, I integrated web3 (for Ethereum) into the project through: npm install web3 To ensure proper integration, I included the follow ...

What is the significance of requiring a specific string in a Typescript Record when it is combined with a primitive type in a union?

I am facing an issue with the following data type: type ErrorMessages = Record<number | 'default', string>; When I declare a variable like const text: ErrorMessages = {403: 'forbidden'}, Typescript points out that default is miss ...

I'm looking to display the message between the specified start date and end date that is selected in the input field

Is it possible to utilize ngOnChange? <div> <label for="start">Start date:</label> <input type="time" name="starts" [(ngModel)]="starts"> <label for="end">End date: </label> <input type="time" name="end" [(ng ...

What is the correct way to specify the data type for the useState hook when I intend to store an array of objects?

My dilemma involves storing an array of objects using the useState hook, but I am struggling with the syntax required to describe the expected type. The type that I want to store is Array<Updates>. Below is the code I have: const [messages, setMessa ...

When trying to pull a component from Svelte, I receive an error message stating "Selection Range

I'm still relatively new to svelte, so I might be handling things incorrectly. Whenever I attempt to separate my button component, regardless of whether I name the component ./Button.svelte, ./Button, Button.svelte, or try variations with capitalizat ...

encountering a problem with angular-datatables implementation

I am currently using Ubuntu 20.04 with npm version 6.14.15, Node.js version 14.17.2, and Angular CLI version 11.2.14. To enhance my working directory, I decided to integrate a data table using the angular-datatables module. In order to successfully utiliz ...

Troubleshooting and setting breakpoints in TypeScript code for Angular Web applications using the Firefox browser

Is there a method to add breakpoints to .typescript source files in my Angular application with Firefox Developer Tools? While I am able to add breakpoints to the generated javascript files, is it possible to debug the .ts source files directly? This quer ...

Having trouble navigating typescript's "import" syntax in conjunction with compiler options like module and choosing between esnext and commonjs?

I am facing an issue with my typescript project that includes mocha tests. Here is a snippet of how the tests start: import { assert } from "chai"; import "@material/mwc-ripple"; //I need to test a script that uses this describe("simple test", () => { ...

Switching out a traditional class component with a functional component within a hook to deduce properties from T

One challenge is to subtract props from T within the withHookFn function using a function instead of a class as successfully done in the withHook function. The code contains comments explaining this issue. Dive into the code for more insights. import Reac ...

An issue has occurred: Failure to execute spawnSync PATH/target/node/node ENOENTNGCC. Please refer to the

Attempting to initiate my angular project using ./mvnw is resulting in an error when the build runs ng build --configuration development. The error message thrown reads as follows: Generating browser application bundles (phase: setup)... [INFO] /home/use ...

React refs should always be validated for null or never values to avoid any potential issues

As I set up a react ref to be used in useEffect, the compiler is throwing an error stating that myRef.current evaluates to never: import React, {useRef, useState} from 'react' export default function RefProblem() { const myRef = useRef(null ...

Adding a CSS class to a component element

I am working with an angular component that looks like this: export class HeaderMainComponent { } This is the HTML structure: <header> <nav> <li>Link 1</li> <li>Link 2</li> </nav> </header> ...

Debugger for Visual Code unable to locate URL in Microsoft Office Add-in

I recently installed the Microsoft Office Add-in Debugger VS code extension, but I'm having trouble getting it to work despite following the instructions. Every time I try, an error message pops up: https://i.sstatic.net/h2FYs.png Upon inspecting my ...

How can I activate a function in one Angular 2 component from another?

I am working with two components named componentA and componentB. They are both siblings and children of componentMother. My goal is to have a button click on componentA trigger a function call on componentB. Would the best approach be using a service wi ...

Angular fails to combine values within routerLink

The issue is straightforward - I have a component that retrieves the last searched items saved in sessionStorage as an array of ListItem objects: export class SearchlistComponent { results = JSON.parse(<string>sessionStorage.getItem("lastSear ...

Ways to invoke main.ts to communicate with an Angular component using Electron

I have a good understanding of how to communicate between an angular app and the electron main thread using IPC. However, in my current scenario, I have threads running in the electron main thread for video processing. After these threads complete their t ...

Sharing variables between components within the same file in Angular 6

I have an Angular 6 application that relies on APIs to function. Within my app, I need to display certain data from the APIs in an Angular Material Dialog. The dialog Component is located alongside the main component used to showcase the API data. However ...