Export StoreWithState interface
See original GitHub issueWhat problem is this solving
I am trying to create generic function for creating base stores. Something like this
interface BaseState {
baseData: ""
};
function defineEnumerationStore<TEnumeration, TAdditionalState, TAdditionalActions>(id: string, additionalState?: TAdditionalState, additionalActions?: TAdditionalActions) {
return defineStore({
id: "...",
state: () => ({
baseData: "",
...additionalState
} as BaseState & TAdditionalState),
actions: {
baseMethod() {
return this.baseData;
},
...additionalActions
} //here I can't type actions object like StoreWithState<> & TAdditionalActions
})
}
I want to be able to provide additional actions and state data to this generic function. My problem is that I can’t type my extended actions object like shown in the code above. Maybe I am doing it wrong way, but I think it would help if StoreWithState interface was exported so I can use it to type my actions object.
Proposed solution
Export type: interface StoreWithState<Id extends string, S extends StateTree>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How can I export an interface that I have imported?
Use the import keyword to bring in something into the type declaration space (as opposed to var which brings it into the variable...
Read more >Typescript errors with pinia 0.5.1 · Issue #504 - GitHub
... 143 | export interface StoreWithState<Id extends string, ... 251 | * Store type to build a store 252 | */ > 253...
Read more >https://unpkg.com/next-redux-wrapper@3.0.0/src/ind...
getInitialProps wrapper got the store with state', store. ... initialProps} store={this.store} />; } }; }; export interface Config { serializeState?:
Read more >https://cdn.jsdelivr.net/npm/pinia@0.5.3/dist/src/...
export interface PiniaPluginContext<Id extends string = string, S extends StateTree = StateTree, G extends GettersTree<S> = GettersTree<S>, A = ActionsTree> ...
Read more >15. Strongly type our store - Angular and NgRx - GitBook
Add an interface and initial state to our spinner reducer. src/app/state/spinner.reducer.ts. export interface State {. isOn: boolean;. }.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I completely missed 2.0.0-alpha.6 version that already has them exported 🤦♂️ as I was using 2.0.0-alpha.5, will try to make a PR for version one today at least.
I pushed a commit to expose the types to v1 and will release the next week or so after adding other changes to align as much as possible with v2