NgXs: TypeError: Class constructor MyState cannot be invoked without 'new'

NgXs: TypeError: Class constructor MyState cannot be invoked without 'new'

我正在将 NgXs 商店集成到我的应用程序中。我已经创建了几个简单的状态并尝试从它们中获取 select 数据,但是当应用程序启动时我收到运行时错误:

TypeError: Class constructor MyState cannot be invoked without 'new'
    at ngxs-store.js:2166
    at Array.map (<anonymous>)
    at selectFromAppState (ngxs-store.js:2162)
    at Store.selectSnapshot (ngxs-store.js:2343)
    ...

最后我发现我忘记提供状态 class 给 NgxsModule

@NgModule({
    imports: [
        CommonModule,
        NgxsModule.forRoot([
            ...
            MyState // this line was missing, so the store cannot instantiate the state
        ], {
            developmentMode: !environment.production
        })
    ],
    exports: [
        NgxsModule
    ]
})
export class StoreModule {}