我正在尝试在生产环境下编译我的 Angular 应用程序,但是遇到了这个错误:
无法确定 /src/testing/translate.service.spec.ts 中 TranslateMockPipe 类的模块!请将 TranslateMockPipe 添加到 NgModule 中以修复此问题。
TranslateMockPipe
类是我声明的一个常见类,并且我在所有测试文件中都在使用它,以避免在所有测试用例中重复相同的代码行。
该类的代码:
@Pipe({ name: "translate" })
class TranslateMockPipe {
transform = (ss) => ss
}
我在我的测试中使用它的方式如下:
TestBed.configureTestingModule({
declarations: [
DemoComponent,
TranslateMockPipe
]
})
如果我运行项目,一切都很顺利,我的测试也没有问题,但当我尝试编译生产版本时会失败。
我该如何忽略这种假类以进行生产构建?