Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Passing rootreducer to the configureStore method fails compilation in Typescript #39

Closed
1 of 7 tasks
cholt0425 opened this issue Aug 17, 2018 · 1 comment
Closed
1 of 7 tasks

Comments

@cholt0425
Copy link

This is a...

  • feature request
  • [ ?] bug report
  • [ X] usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 8.11.3
Typescript Version: 2.9.3
Angular Version: 6.1.3
@angular-redux/store version: ^9.0.0
@angular/cli version: (if applicable): 6.1.2
OS: Windows

Expected Behavior:

I have the following types and reducers defined (abbreviated for clarity)


//-- Normalized model objects suitable for the store that use string keys --//
export interface NormalizedObjectsStr<T> {
    byId: LookupNum<T>;
    allIds: number[];
}

//-- Normalized model objects suitable for the store that use string keys --//
export interface NormalizedObjectsNum<T> {
    byId: { [id: number]: T };
    allIds: number[];
}

//-- Client side store of our data models --//
export interface ClientDataStore {
    categories: NormalizedObjectsNum<Category>
    attributes: NormalizedObjectsNum<Attribute>
}


// Definition of application state
export interface IAppState {
    entities?: ClientDataStore;
    classfnAppState?: IClassfnAppState;
}

//-- Entity reducers --//
const categoriesByIdReducer: Reducer<LookupNum<Category>, FluxStandardAction<Category | number>> = (state, action) => {
    switch (action.type) {
        default: { return state; }
    }
}

const allCategoryIdsReducer: Reducer<number[], FluxStandardAction<Category | number>> = (state, action) => {
    switch (action.type) {
        default: {
            return state;
        }
    }
}

const attributesByIdReducer: Reducer<LookupNum<Attribute>, FluxStandardAction<Category | number>> = (state, action) => {
    switch (action.type) {
        default: { return state; }
    }
}

const allAttributesIdsReducer: Reducer<number[], FluxStandardAction<Attribute | number>> = (state, action) => {
    switch (action.type) {
        default: {
            return state;
        }
    }
}


const categoriesReducer = combineReducers({
    byId: categoriesByIdReducer,
    allIds: allCategoryIdsReducer
});

const attributesReducer = combineReducers({

});

const entityReducer = combineReducers({
    categories: categoriesReducer,
    attributes: attributesReducer
});


//-- Create Root Reducer --//
export default combineReducers({
    entities: entityReducer,
    classfnAppState: classfnRootReducer
});

When I configure the store with this call:

import appRootReducer from './reducers';
store.configureStore(
            appRootReducer,
            INITIAL_STATE,
            [createLogger()],
            devTools.isEnabled() ? [devTools.enhancer()] : []);

It should compile and run.

Actual Behavior:

It won't compile with an error saying the reducer type is wrong. Notice it seems to have lost the type ClientDataStore for some reason. Because I'm combining multiple reducers across the state it seems to loose the intermediate interface definition.

Stack Trace/Error Message:

ERROR in src/app/classification/classification.component.ts(14,18): error TS2339: Property 'entities' does not exist on type 'IAppStateClassfn'.
src/app/store/store.module.ts(33,13): error TS2345: Argument of type 'Reducer<{ entities: { categories: any; attributes: any; }; classfnAppState: IClassfnAppState; }, ...' is not assignable to parameter of type 'Reducer<IAppState, AnyAction>'.
Types of parameters 'state' and 'state' are incompatible.
Type 'IAppState' is not assignable to type '{ entities: { categories: any; attributes: any; }; classfnAppState: IClassfnAppState; }'.
Property 'entities' is optional in type 'IAppState' but required in type '{ entities: { categories: any; attributes: any; }; classfnAppState: IClassfnAppState; }'.

Additional Notes:

(optional)

@cholt0425
Copy link
Author

I apologize...This is more of a redux question not angular-redux.

github-actions bot pushed a commit to adrianiy/platform that referenced this issue Sep 28, 2021
# ngredux-store-v1.0.0 (2021-09-28)

### Bug Fixes

* fix eslint ([ab4d1d3](ab4d1d3))
* **build:** No chai for you ([#209](https://github.com/AdrianInsua/platform/issues/209)) ([be35f03](be35f03))
* **deps:** Change zone.js version ([#222](https://github.com/AdrianInsua/platform/issues/222)) ([e62e149](e62e149))
* **example:** Fix local dev mode ([angular-redux#80](https://github.com/AdrianInsua/platform/issues/80)) ([angular-redux#81](https://github.com/AdrianInsua/platform/issues/81)) ([b06721f](b06721f))
* **ngReduxModule:** Generate metadata ([#237](https://github.com/AdrianInsua/platform/issues/237)) ([8b4b9d8](8b4b9d8))
* **package.json:** add redux as dependencies ([angular-redux#132](https://github.com/AdrianInsua/platform/issues/132)) ([5fdeb19](5fdeb19))

### chore

* **build:** use ng-packagr ([angular-redux#37](https://github.com/AdrianInsua/platform/issues/37)) ([dffe23a](dffe23a)), closes [angular-redux#9](https://github.com/AdrianInsua/platform/issues/9)
* **linting:** add global tslint rules ([angular-redux#35](https://github.com/AdrianInsua/platform/issues/35)) ([336cc60](336cc60)), closes [angular-redux#4](https://github.com/AdrianInsua/platform/issues/4)

### Features

* add bootstraping script ([3fd7b32](3fd7b32))
* add new devtools window prop name ([angular-redux#58](https://github.com/AdrianInsua/platform/issues/58)) ([55b15a6](55b15a6))
* bump angular version to 11.0.5 ([1b8bb72](1b8bb72))
* Introduced a new function called provideStore() which accepts a already created Redux store ([angular-redux#142](https://github.com/AdrianInsua/platform/issues/142)) ([a6c4aaf](a6c4aaf)), closes [angular-redux#141](https://github.com/AdrianInsua/platform/issues/141)
* refactor packages to match new ng-packager ([710edef](710edef))
* upgrade to angular 7 ([angular-redux#72](https://github.com/AdrianInsua/platform/issues/72)) ([18d9245](18d9245)), closes [angular-redux#65](https://github.com/AdrianInsua/platform/issues/65) [angular-redux#66](https://github.com/AdrianInsua/platform/issues/66) [angular-redux#67](https://github.com/AdrianInsua/platform/issues/67) [angular-redux#68](https://github.com/AdrianInsua/platform/issues/68) [angular-redux#69](https://github.com/AdrianInsua/platform/issues/69) [angular-redux#70](https://github.com/AdrianInsua/platform/issues/70) [angular-redux#71](https://github.com/AdrianInsua/platform/issues/71) [angular-redux#74](https://github.com/AdrianInsua/platform/issues/74) [angular-redux#79](https://github.com/AdrianInsua/platform/issues/79)
* Typescript Port ([angular-redux#33](https://github.com/AdrianInsua/platform/issues/33)) ([33ea991](33ea991)), closes [angular-redux#35](https://github.com/AdrianInsua/platform/issues/35) [angular-redux#36](https://github.com/AdrianInsua/platform/issues/36) [angular-redux#37](https://github.com/AdrianInsua/platform/issues/37) [angular-redux#38](https://github.com/AdrianInsua/platform/issues/38) [angular-redux#39](https://github.com/AdrianInsua/platform/issues/39) [angular-redux#52](https://github.com/AdrianInsua/platform/issues/52) [angular-redux#50](https://github.com/AdrianInsua/platform/issues/50) [angular-redux#55](https://github.com/AdrianInsua/platform/issues/55) [angular-redux#53](https://github.com/AdrianInsua/platform/issues/53)
* **aot:** Support AoT - [#223](https://github.com/AdrianInsua/platform/issues/223) ([#226](https://github.com/AdrianInsua/platform/issues/226)) ([a6d7826](a6d7826))
* **dispatch:** Create dispatch decorator ([#385](https://github.com/AdrianInsua/platform/issues/385)) ([4513566](4513566))

### BREAKING CHANGES

* Upgrades Angular dependencies to v7
* **build:** - changes the output to conform to the Angular Package Format. This may cause subtle differences in consumption behaviour
- peer dependencies have been corrected to actual dependencies
* **linting:** - ConnectArray has been renamed to ConnectArrayDirective
- ReactiveConnect has been renamed to ReactiveConnectDirective
- Connect has been renamed to ConnectDirective
- interfaces with an "I" prefix have had that prefix removed (e.g "IAppStore" -> "AppStore")
github-actions bot pushed a commit to adrianiy/platform that referenced this issue Sep 28, 2021
# @adrian.insua/ngredux-store-v1.0.0 (2021-09-28)

### Bug Fixes

* change package names to be user scoped ([c0c9d1d](c0c9d1d))
* fix eslint ([ab4d1d3](ab4d1d3))
* **build:** No chai for you ([#209](https://github.com/AdrianInsua/platform/issues/209)) ([be35f03](be35f03))
* **deps:** Change zone.js version ([#222](https://github.com/AdrianInsua/platform/issues/222)) ([e62e149](e62e149))
* **example:** Fix local dev mode ([angular-redux#80](https://github.com/AdrianInsua/platform/issues/80)) ([angular-redux#81](https://github.com/AdrianInsua/platform/issues/81)) ([b06721f](b06721f))
* **ngReduxModule:** Generate metadata ([#237](https://github.com/AdrianInsua/platform/issues/237)) ([8b4b9d8](8b4b9d8))
* **package.json:** add redux as dependencies ([angular-redux#132](https://github.com/AdrianInsua/platform/issues/132)) ([5fdeb19](5fdeb19))

### chore

* **build:** use ng-packagr ([angular-redux#37](https://github.com/AdrianInsua/platform/issues/37)) ([dffe23a](dffe23a)), closes [angular-redux#9](https://github.com/AdrianInsua/platform/issues/9)
* **linting:** add global tslint rules ([angular-redux#35](https://github.com/AdrianInsua/platform/issues/35)) ([336cc60](336cc60)), closes [angular-redux#4](https://github.com/AdrianInsua/platform/issues/4)

### Features

* add bootstraping script ([3fd7b32](3fd7b32))
* add new devtools window prop name ([angular-redux#58](https://github.com/AdrianInsua/platform/issues/58)) ([55b15a6](55b15a6))
* bump angular version to 11.0.5 ([1b8bb72](1b8bb72))
* Introduced a new function called provideStore() which accepts a already created Redux store ([angular-redux#142](https://github.com/AdrianInsua/platform/issues/142)) ([a6c4aaf](a6c4aaf)), closes [angular-redux#141](https://github.com/AdrianInsua/platform/issues/141)
* refactor packages to match new ng-packager ([710edef](710edef))
* upgrade to angular 7 ([angular-redux#72](https://github.com/AdrianInsua/platform/issues/72)) ([18d9245](18d9245)), closes [angular-redux#65](https://github.com/AdrianInsua/platform/issues/65) [angular-redux#66](https://github.com/AdrianInsua/platform/issues/66) [angular-redux#67](https://github.com/AdrianInsua/platform/issues/67) [angular-redux#68](https://github.com/AdrianInsua/platform/issues/68) [angular-redux#69](https://github.com/AdrianInsua/platform/issues/69) [angular-redux#70](https://github.com/AdrianInsua/platform/issues/70) [angular-redux#71](https://github.com/AdrianInsua/platform/issues/71) [angular-redux#74](https://github.com/AdrianInsua/platform/issues/74) [angular-redux#79](https://github.com/AdrianInsua/platform/issues/79)
* Typescript Port ([angular-redux#33](https://github.com/AdrianInsua/platform/issues/33)) ([33ea991](33ea991)), closes [angular-redux#35](https://github.com/AdrianInsua/platform/issues/35) [angular-redux#36](https://github.com/AdrianInsua/platform/issues/36) [angular-redux#37](https://github.com/AdrianInsua/platform/issues/37) [angular-redux#38](https://github.com/AdrianInsua/platform/issues/38) [angular-redux#39](https://github.com/AdrianInsua/platform/issues/39) [angular-redux#52](https://github.com/AdrianInsua/platform/issues/52) [angular-redux#50](https://github.com/AdrianInsua/platform/issues/50) [angular-redux#55](https://github.com/AdrianInsua/platform/issues/55) [angular-redux#53](https://github.com/AdrianInsua/platform/issues/53)
* **aot:** Support AoT - [#223](https://github.com/AdrianInsua/platform/issues/223) ([#226](https://github.com/AdrianInsua/platform/issues/226)) ([a6d7826](a6d7826))
* **dispatch:** Create dispatch decorator ([#385](https://github.com/AdrianInsua/platform/issues/385)) ([4513566](4513566))

### BREAKING CHANGES

* Upgrades Angular dependencies to v7
* **build:** - changes the output to conform to the Angular Package Format. This may cause subtle differences in consumption behaviour
- peer dependencies have been corrected to actual dependencies
* **linting:** - ConnectArray has been renamed to ConnectArrayDirective
- ReactiveConnect has been renamed to ReactiveConnectDirective
- Connect has been renamed to ConnectDirective
- interfaces with an "I" prefix have had that prefix removed (e.g "IAppStore" -> "AppStore")
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

1 participant