Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

NG1001: Decorator argument is not an object literal

Description

To make the metadata extraction in the Angular compiler faster, the decorators @NgModule, @Pipe, @Component, @Directive, and @Injectable accept only object literals as arguments.

This is an intentional change in Ivy, which enforces stricter argument requirements for decorators than View Engine. Ivy requires this approach because it compiles decorators by moving the expressions into other locations in the class output.


Debugging the error

Move all declarations:

      
      const moduleDefinition = {…}

@NgModule(moduleDefinition)
export class AppModule {
    constructor() {}
}
    

into the decorator:

      
      @NgModule({…})
export class AppModule {
    constructor() {}
}