Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Where is redux-saga definitions? #2013

Open
OnkelTem opened this issue Feb 6, 2020 · 10 comments
Open

Where is redux-saga definitions? #2013

OnkelTem opened this issue Feb 6, 2020 · 10 comments

Comments

@OnkelTem
Copy link

OnkelTem commented Feb 6, 2020

I use WebStorm for development of create-react-app applications.
So I have all the regular things installed and redux-saga among them.

Currently the following sequence

import createSagaMiddleware from "redux-saga";
const sagaMiddleware = createSagaMiddleware();
sagaMiddleware.run(rootSaga);

leads to an IDE warning on sagaMiddleware.run line:

Unresolved function or method run()
Inspection info: Checks that called functions are valid. The validation works in JavaScript, html or jsp files.

So it seems that I don't have any proper type definitions installed.

I tried to search for them in the WebStorm types repository but found nothing.

I also searched for @types/redux-saga package on npmjs and found this one: https://www.npmjs.com/package/@types/redux-saga

As you can see it shows the deprecation message:

This is a stub types definition for redux-saga (https://github.com/redux-saga/redux-saga). redux-saga provides its own type definitions, so you don't need @types/redux-saga installed!

Yeah, cool. It means I should have it already, should I? Then where is it?

@stianjensen
Copy link

You're probably looking for the package https://www.npmjs.com/package/@redux-saga/types instead, published from the packages/types folder of this repository: https://github.com/redux-saga/redux-saga/tree/master/packages/types

@Andarist
Copy link
Member

We publish TS types to npm and they are available from the IDE. Not sure why WebStorm doesn't pick them up but I'm afraid that you would have to research this on your own.

@tannaz97shr
Copy link

That's OK. It works without WebStorm recognizing the function.

@artyom-88
Copy link

Got the same problem with WebStorm

@orekav
Copy link

orekav commented Jun 7, 2020

I am facing the same issue.
I went to:
Webstorm -> File -> Settings -> Languages & Frameworks -> JavaScript -> Libraries -> Downloads

But it doesn't show "redux-saga", it does show "redux-saga-routines" & "redux-saga-tester".
I also have set the node_modules folder from the project but still do not recognize it.

In Visual Studio Code works perfectly

@OnkelTem
Copy link
Author

OnkelTem commented Jun 8, 2020

@orekav I don't have any redux or saga related libraries there.

But it works for me now, although my initialization is done in a *.ts file now, not sure if it matters or not.

@neurosnap
Copy link
Member

Closing due to inactivity.

@tsopeh
Copy link

tsopeh commented Aug 28, 2023

Sorry for reopening this issue but I've encountered a similar issue. I'm working on a mixed javascript/typescript project using WebStorm; when I import an effect in a js file, I'm not getting any completion or type hints.

import { race } from "redux-saga/effects";

But if I change the import path to:

import { race } from "@redux-saga/core/effects";

everything starts working as expected.

Is importing from @redux-saga/core/effects considered a bad practice?

@neurosnap
Copy link
Member

neurosnap commented Aug 28, 2023

So generally speaking, yes, it is not ideal to rely on internal packages because those paths are subject to change and we make no guarantees that they will exist.

If we follow the breadcrumbs for how redux-saga/effects package is structured:

As you can see in the second bullet, that's how we are forwarding the types to the user through redux-saga/effects.

We have no plans on changing the internal structure of this project. I'm not entirely sure why your IDE is not picking up the types. I'm curious, if you reference redux-saga/effects inside your TS-enabled files, does tsc check the types properly?

@neurosnap neurosnap reopened this Aug 28, 2023
@tsopeh
Copy link

tsopeh commented Aug 28, 2023

Hi @neurosnap, thanks for answering 🚀

I can confirm that (locally in WebStorm) type inference works properly for redux-saga/effects, if I change the file extension from .js to .ts. Unfortunately this is not a viable solution for a large project that is mostly written in JS.

Locally, VS Code works fine, but I've created a minimal repro on StackBlitz (remote editor) that demonstrates my issue for both TS and JS files.

Unfortunately, this issue seems to be inconsistent between local and remote editors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants