Comments (11)
Hi @nareshbhatia I took a look at your repo - it looks like you're using the redux typings from definitely typed. Redux 3.4 now ships with its own official typings in npm.
Let me suggest a few minor changes to your seed:
Change 1: In your typings.json
you need to remove the entry for Redux. Then do
rm -rf typings; typings install
This will let typescript pull in the correct typings from your node_modules
.
Change 2:
The official redux typings require an initial state in createStoreWithMiddleware
. So in your main.ts
, online 13, I suggest something like:
const store = createStoreWithMiddleware(rootReducer, {});
Change 3:
Finally, the redux-thunk typings are very out-of-date in definitely-typed, and don't play well with the official redux typings. Hopefully me or someone else will have time to make a PR against redux-thunk for correct typings.
For now in my project I use redux-thunk in untyped form: instead of import
-ing it, I do:
const thunk = require('redux-thunk').default;
Hope, this helps,
Seth
from store.
Is this the appropriate place to ask this question? Happy to take it somewhere else if more appropriate.
from store.
Hey Narash,
I'm currently on a trip, so didn't had time to take a look at your issue!
Will try to do so soon.
Might be a good idea to duplicate your issue on angular-seed too.
Thanks
from store.
Good idea - I will create an issue on angular2-seed too.
from store.
I have an issue logged for this on angular2-seed. More importantly, I created a new project that combines angular2-seed + ng2-redux: https://github.com/archfirst/angular2-seed-redux. I had to install bunch of type definitions that I did not see in the README steps here. Anyway, I am currently stuck on a very basic error:
src/client/main.ts(7,25): error TS2307: Cannot find module 'ng2-redux'.
I can't figure this one out. I have installed the ng2-redux package and it exists in my node_modules folder. So I can't understand why the compiler doesn't find it.
I would really appreciate if someone on this group can help me get this combination working. Thanks in advance for all your help.
from store.
Hey Naresh,
Typings for ng2-redux
is currently a work in progress.
Everything is being rewritten directly in TypeScript (here).
I think @e-schultz and @bennett000 are going to release a beta on npm very soon.
from store.
@nareshbhatia src/client/main.ts(7,25): error TS2307: Cannot find module 'ng2-redux'
my guess is that this module is not being found (by tsc
) because it lacks typings.
- One solution to this would be to use a library like
typings
to installng2-redux
typings from a source like Definitely typed. - Another solution would be to use the beta version of
ng2-redux
which can be installed with a command likenpm install --save-dev ng2-redux@beta
.
Additionally you can take a look at this starter which uses ng2-redux and Angular 2 to assemble a minimal "starter" application.
from store.
@nareshbhatia: we just released version 2.2.3 which has been rewritten in typescript and thus includes typings. That should resolve your TS2307 error at least.
Can you give it a try?
from store.
Thanks @SethDavenport. The TS2307 is gone. However, I am getting the following errors now.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(13,24): error TS2315: Type 'Store' is not generic.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(20,34): error TS2315: Type 'Store' is not generic.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(30,54): error TS2315: Type 'Dispatch' is not generic.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(30,78): error TS2315: Type 'ActionCreator' is not generic.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(30,110): error TS2305: Module 'Redux' has no exported member 'ActionCreatorsMapObject'.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(44,90): error TS2305: Module 'Redux' has no exported member 'Unsubscribe'.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(56,48): error TS2305: Module 'Redux' has no exported member 'Unsubscribe'.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(66,52): error TS2305: Module 'Redux' has no exported member 'Action'.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/ng-redux.d.ts(70,32): error TS2305: Module 'Redux' has no exported member 'Action'.
/Users/nbhati/projects/angular2-seed-redux/node_modules/ng2-redux/lib/components/provider.d.ts(3,44): error TS2315: Type 'Store' is not generic.
You should be able to reproduce them on my project: https://github.com/archfirst/angular2-seed-redux
from store.
Thanks @SethDavenport. That fixes all the compile errors.
from store.
Happy to help.
from store.
Related Issues (20)
- One More Time, Error: Actions must be plain objects. Use custom middleware for async actions
- Extend peer dependencies to Angular 7 HOT 2
- "NullInjectorError: No provider for NgZone" after upgrade to Angular 6 and angular-redux/store 9 HOT 2
- `window.devToolsExtension` is deprecated
- Storybook stories with @select HOT 2
- Metadata collected contains an error that will be reported at runtime: Lambda not supported.
- Request for articles/epics.md HOT 2
- Did you forget to configure your store? when running from a dist directory
- Select fires on unrelated store changes.
- Using @select decorator with @Input HOT 1
- Compiler Error when implementing Redux-Thunk Action
- @select decorator error: property has no initializer and is not definitely assigned in the constructor.
- Sharing common store between multiple modules ?
- Support for Angular 8? HOT 5
- installing angular-redux/store on angular 8.0.0 causes warning on missing peer dependencies (@angular/core@^7.0.0) HOT 2
- NgRedux<RootState> HOT 6
- Dispatch an action outside of ngZone HOT 1
- not understanding how to test subscription side effects HOT 1
- An unexpected error occurred: "https://registry.yarnpkg.com/@angular-redux%2fstore: read ETIMEDOUT" HOT 1
- Angular Version 12 is not supporting. HOT 1
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 store.