Comments (2)
I looked more into tests such as https://github.com/ngrx/platform/blob/main/modules/signals/spec/types/signal-store.types.spec.ts, and it turned out that this syntax would work, i.e. with <_>
in function declaration:
const withFooFeature = <_>() =>
signalStoreFeature(
{
state: type<{ foo: number }>()
},
withState({})
);
const withBarFeature = <_>() =>
signalStoreFeature(
{
state: type<{ bar: number }>()
},
withState({})
);
export const FooBarStore = signalStore(
withState({
foo: 10,
bar: 20
}),
withComputed(store => ({
foofoo: computed(() => store.foo() * store.foo()),
barbar: computed(() => store.bar() * store.bar())
})),
withFooFeature(),
withBarFeature()
);
It is not very intuitive, so I think documentation update would make sense.
from platform.
Correct, it can be fixed with unused generic. And I agree with you, this is unintuitive TypeScript behavior.
Once we change SignalStore types to disable property/method overriding, the type implementation will be simpler, so this issue may disappear. Let's see.
from platform.
Related Issues (20)
- untracked for all methods? HOT 4
- @ngrx/signals: ability to save entity class instance on updateEntity() HOT 1
- Expose more models to the public API: SignalStoreFeatureResult and InputSignalStore<Input>
- Using a custom generic function for defining props in createActionGroup results in weird TypeScript errors HOT 4
- @ngrx/effects/src/effect_creator.d.ts:12:43 - error TS2313: Type parameter 'OT' has a circular constraint. HOT 17
- Schematics 'feature' gives error "Property 'entity' does not match the schema. 'false' should be a 'boolean'." HOT 8
- `patchState` TypeScript v5.4 compilation error HOT 3
- updater-explicit-return-type No longer needed with NoInfer HOT 2
- Cannot generate feature inside module with schematics HOT 2
- RFC: Allow constructor injection of SignalStore
- RFC: SignalStore with WritableSignals and ReadOnlySignalStore HOT 8
- Signal Store with Angular SSR initiate store in every injected component HOT 2
- Type 'Unsubscribable' must have a '[Symbol.iterator]()' method that returns an iterator. HOT 2
- Return type of selectQueryParam is incorrect HOT 2
- SignalStore Methods code snipped has probably a flaw HOT 4
- eslint plugin should use correct version of 'concatLatestFrom' in autofix for rule 'prefer-concat-latest-from' HOT 5
- Provide properly typed selectors example for CustomSerializer
- No usage notes for `tapResponse`, `concatLatestFrom` operators. HOT 1
- Ngrx dependency injection issue with esbuild/build-angular:application HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from platform.