You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exporttypeEntityIdProps<Entity>={[KinkeyofEntityasKextendsEntityId ? K : never]: Entity[K];};
👆 By applying the changes that you proposed, the EntityIdProps type will always return all props because K extends EntityId will always be true (except when some key is a symbol).
The idea with:
exporttypeEntityIdProps<Entity>={[KinkeyofEntityasEntity[K]extendsEntityId ? K : never]: Entity[K];};
is to exclude all properties whose values are not string | number (not keys), because they cannot be used as identifiers.
But anyway, thanks for reporting this! Let's try to find some workaround.
Which @ngrx/* package(s) are the source of the bug?
signals
Minimal reproduction of the bug/regression with instructions
I am trying to create a signal store feature using generics and I stumbled upon a typing error when trying to use the idKey:
https://ngrx.io/guide/signals/signal-store/entity-management#customized-id-property
I have the following feature:
I checked how the type definition is made internally and tried to reproduce it with as concise an example as I could.
context:
usingType()
function is used to mimick what anyset*
method would do if you accessed the config object.Current faulty behavior
Expected behavior
The expected behavior is that
uuid
is recognized as a key with the correct type.Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
"@ngrx/signals": "17.1.0"
Other information
If you change the type of
EntityIdProps
toWorking playground
Then you will have the correct typing.
Seems like the type is not correctly resolved when using the indexed property accessor via generics which extends a known type.
I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: