ngxs / store

🚀 NGXS - State Management for Angular
http://ngxs.io
MIT License
3.54k stars 406 forks source link

🐞[BUG]: Dev mode check for createPropertySelectors prevents valid usage within state class #2209

Closed markwhitfeld closed 3 months ago

markwhitfeld commented 3 months ago

Affected Package

The issue is caused by package @ngxs/store package

Is this a regression?

This issue has always been present, since the introduction of the feature.

Description

The createPropertySelectors utility checks that the provided selector is a valid selector. This is great, but if the utility is used within a state class it fails this check (during ngDevMode) because the @State decorator has not yet added the selector metadata.

🔬 Minimal Reproduction

https://stackblitz.com/edit/tptxd8-kxtgub?file=src%2Fapp%2Fcookie%2Fcookie.state.ts This reproduction runs the development mode angular server by default. You will see the error in the console of the preview window (when opened in a new tab).

If you run the production mode server, you will see no error and the app will work: npm start -- -c=production

🔥 Exception or Error

image

Environment


Libs:
- @angular/core version: ^18.0.0
- @ngxs/store version: 18.1.1

markwhitfeld commented 3 months ago

cc @dmrickey