Polymer / pwa-helpers

Small helper methods or mixins to help you build web apps.
BSD 3-Clause "New" or "Revised" License
439 stars 48 forks source link

error TS2307: Cannot find module 'redux'. #65

Closed bennypowers closed 4 years ago

bennypowers commented 4 years ago

Repro:

npm i -S pwa-helpers
npm i -D typescript
echo "import { installRouter } from 'pwa-helpers';" > app.js
npx tsc app.js --allowJs --checkJs --noEmit

Result:

node_modules/pwa-helpers/connect-mixin.d.ts:10:36 - error TS2307: Cannot find module 'redux'.

10 import { Store, Unsubscribe } from 'redux';
                                      ~~~~~~~

node_modules/pwa-helpers/connect-mixin.d.ts:42:58 - error TS2307: Cannot find module 'redux'.

42 export declare const connect: <S>(store: Store<S, import("redux").AnyAction>) => <T extends Constructor<CustomElement>>(baseElement: T) => {
                                                            ~~~~~~~

node_modules/pwa-helpers/lazy-reducer-enhancer.d.ts:10:50 - error TS2307: Cannot find module 'redux'.

10 import { ReducersMapObject, StoreEnhancer } from 'redux';
                                                    ~~~~~~~

node_modules/pwa-helpers/lazy-reducer-enhancer.d.ts:36:75 - error TS2307: Cannot find module 'redux'.

36 export declare const lazyReducerEnhancer: (combineReducers: typeof import("redux").combineReducers) => StoreEnhancer<LazyStore, {}>;
                                                                             ~~~~~~~

Found 4 errors.

Expected: no errors

fernandopasik commented 4 years ago

maybe is not specified in peerDependencies but you need to install redux as well

npm i -S pwa-helpers redux

bennypowers commented 4 years ago

Indeed that would work, but my project doesn't use redux. In fact, I don't even import the redux helpers.

If pwa-helpers relies on redux, perhaps it should be listed as a dependency

fernandopasik commented 4 years ago

I see, you are right then, it shouldn't be an error since you are only importing a module that doesn't use redux.

No, it shouldn't be on dependencies because it would be downloaded and you don't need it if you are not using redux. That's why I suggested to be on peerDependencies, as those can be optional

fernandopasik commented 4 years ago

As a temporary solution try

import { installRouter } from 'pwa-helpers/router';
bennypowers commented 4 years ago

yeah that does it