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
Type 'Omit<NamedEntitySignals<Entity, Collection>, FeatureResultKeys<{ state: NamedCallStatusState<Collection>; signals: NamedCallStatusComputed<...>; methods: NamedCallStatusMethods<...>; }>> & { [K in Collection as `is${Capitalize<string & K>}Loading`]: Signal<...>; } & { [K in Collection as `is${Capitalize<string & K>}...' is not assignable to type 'NamedEntitySignals<Entity, Collection>'.
After a lot of investigation this is cause by the way the types are merged in ngrx-signals
This is use to combine to SignalStoreFeatures and if First and Second have the same props the Second will override the First;
The following could fix the issue but it has the problem that if there is two signalstore with the same prop types, the generate prop will have both types the First and Second in an or
type MergeTwoFeatureResults<First extends SignalStoreFeatureResult, Second extends SignalStoreFeatureResult> = First & Second;
Then you can not cast the result to First even though it should work
Small duplication of the problem
exporttypeEntityState<Entity>={entityMap: Record<string|number,Entity>;ids: string|number[];};exporttypeNamedEntityState<Entity,Collectionextendsstring>={[KinkeyofEntityState<Entity>as `${Collection}${Capitalize<K>}`]: EntityState<Entity>[K];};exporttypeNamedCallStatusState<Propextendsstring>={[KinPropas `${K}CallStatus`]: 'init'|'loading'|'loaded';};exportfunctionwithEntityMethods<Entityextends{id: string|number},constCollectionextendsstring,>(entity: Entity,collection: Collection){typeCombine=Omit<NamedEntityState<Entity,Collection>,keyofNamedCallStatusState<Collection>>&NamedCallStatusState<Collection>;// fails with: Type 'Combine' is not assignable to type 'NamedEntityState<Entity, Collection>'.lety: NamedEntityState<Entity,Collection>={}asunknownasCombine;// workaround use anylety2: NamedEntityState<Entity,any>={}asunknownasCombine;// next workstypeCombine2=Omit<NamedEntityState<Entity,'apps'>,keyofNamedCallStatusState<'apps'>>&NamedCallStatusState<'apps'>
The only way I manage to work around this is using // @ts-ignore and a any
But this will affect the other normal cases , because it will not error when a trait has a dependency missing like withEntitiesLocalPagination will not do a compile error if withEntities is not there , so we will depend on throwing runtime errors to indicate if a dependency is missing but I dont want to go that route, because devs could introduce errors that are only visible when running the app.
I will keep investigating options
The text was updated successfully, but these errors were encountered:
Currently we can not create a custom store features with generics that use entity and collection pass to the withEntities* for example
We get the following error
After a lot of investigation this is cause by the way the types are merged in ngrx-signals
This is use to combine to SignalStoreFeatures and if First and Second have the same props the Second will override the First;
The following could fix the issue but it has the problem that if there is two signalstore with the same prop types, the generate prop will have both types the First and Second in an or
The way is currently done doesnt work I beleive because of the following bug in typescript
microsoft/TypeScript#28884 (comment)
The basic problem is if we have two types First and Second are merge them using the following to override props
Then you can not cast the result to First even though it should work
Small duplication of the problem
The only way I manage to work around this is using // @ts-ignore and a any
There is another way is to use more any of the in the types withEntities* like
But this will affect the other normal cases , because it will not error when a trait has a dependency missing like withEntitiesLocalPagination will not do a compile error if withEntities is not there , so we will depend on throwing runtime errors to indicate if a dependency is missing but I dont want to go that route, because devs could introduce errors that are only visible when running the app.
I will keep investigating options
The text was updated successfully, but these errors were encountered: