At first glance, it seems a default behavior of angular component life cycle logic that because of component properties did not initialized yet so stream$ cannot have assignment before component initialization complete:
@Component({
selector: 'app-component',
template: `<p>app works!</p>`,
})
export class AppComponent implements OnInit {
@Select(AppState.getItems)
stream$: Observable<string[]>;
firstItemStream$: Observable<{ selectedItem: string }> = this.stream$ // error occurs here
.pipe(
find(({ itemId }) => itemId === 0),
);
...
Quoted from NgXs:
APP_INITIALIZER is resolved after NGXS states are initialized. They are initialized by the NgxsModule that is imported into the AppModule. The ngxsOnInit method on states is also invoked before the APP_INITIALIZER token is resolved.
Above code works as expected but typescript error still occurs. Is there any workaround from this?
Also I decided to not open an issue to typescript opensource project because of it might also be about NgXs lifecycle itself.