Update from Angular 8 to 9 leads to "ReferenceError: SomeAbstractModelClass is not defined" for production build

Update from Angular 8 to 9 leads to "ReferenceError: SomeAbstractModelClass is not defined" for production build

我更新了一个Angular 8 app to Angular 9。如果我使用 ng serve 启动应用程序,一切运行良好,但如果我使用 ng serve --prod 启动应用程序,我会在运行时收到以下错误。:

ReferenceError: SomeAbstractModelClass is not defined
    at http://localhost:4200/main.js:1:330907
    at Module.zUnb (http://localhost:4200/main.js:1:331001)
    at l (http://localhost:4200/runtime.js:1:552)
    at Object.0 (http://localhost:4200/main.js:1:96)
    at l (http://localhost:4200/runtime.js:1:552)
    at t (http://localhost:4200/runtime.js:1:421)
    at Array.r [as push] (http://localhost:4200/runtime.js:1:293)
    at http://localhost:4200/main.js:1:47

我不知道可能是什么问题,因为所有内容都带有一些警告。

WARNING in .../projects/apps/editor/src/test.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

我也试过禁用 Ivy。:

  "angularCompilerOptions": {
    "enableIvy": false
  }

然后我收到以下错误消息。:

ReferenceError: SomeOtherModelClass is not defined
    at http://localhost:4200/main.js:1:364834
    at Module.zUnb (http://localhost:4200/main.js:1:364923)
    at l (http://localhost:4200/runtime.js:1:552)
    at Object.0 (http://localhost:4200/main.js:1:96)
    at l (http://localhost:4200/runtime.js:1:552)
    at t (http://localhost:4200/runtime.js:1:421)
    at Array.r [as push] (http://localhost:4200/runtime.js:1:293)
    at http://localhost:4200/main.js:1:47

SomeOtherModelClass 是一个 class 扩展了另一个抽象 class.

导致该问题的原因可能是什么?如果我能提供更多信息,请告诉我。

这似乎是 bug

如果在 tsconfig.json 中将 "emitDecoratorMetadata" 设置为 false,应用程序也会在生产模式下运行。

如前所述,根 tsconfig.json 中的 "emitDecoratorMetadata": false 修复了它。

我还需要将它设置为 true 用于我的 src/tsconfig.test.json 用于 Jest,否则我一直收到此 DI 错误:

Can't resolve all parameters for StoreService: (?, ?)