跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

Argument Not Literal ​

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:

ts
const moduleDefinition = {…}

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

into the decorator:

ts

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

基于 MIT 许可证发布。