Open ptandler opened 1 month ago
signals
The withEntities feature uses EntityId for the entities' id, which is defined as export type EntityId = string | number.
withEntities
EntityId
export type EntityId = string | number
We have a use case where we need to narrow down the type of the id to (e.g.) UUID (or some other sub-type of string).
UUID
string
So I'd suggest adding a second optional type arg to withEntities() like this:
withEntities()
export declare function withEntities<Entity, Id extends EntityId = EntityId>(): SignalStoreFeature<EmptyFeatureResult, { state: EntityState<Entity, Id>; computed: EntityComputed<Entity, Id>; methods: {}; }>;
At the moment we need to cast the id from EntityId to UUID:
signalStore( withEntities<V>(), withMethods((store) => ({ allIds(): K[] { return store.ids() as K[]; }, //... )
Which @ngrx/* package(s) are relevant/related to the feature request?
signals
Information
The
withEntities
feature usesEntityId
for the entities' id, which is defined asexport type EntityId = string | number
.We have a use case where we need to narrow down the type of the id to (e.g.)
UUID
(or some other sub-type ofstring
).So I'd suggest adding a second optional type arg to
withEntities()
like this:Describe any alternatives/workarounds you're currently using
At the moment we need to cast the id from
EntityId
toUUID
:I would be willing to submit a PR to fix this issue