Comments (8)
Went ahead and filed https://youtrack.jetbrains.com/issue/WEB-42559 .
I'll go ahead and close the issue, since this doesn't appear to be a problem in RTK itself. Thanks for reporting it, though!
from rtk-github-issues-example.
That doesn't sound right. Can you post the code that generated the displayRepo
action creator?
Erm. Wait, this is on the example repo.
Where are you seeing that issue, specifically? Is it just from cloning the repo, in one of the sandboxes, or something else?
FWIW, if I open the repo as of its final commit and hover over displayRepo
, I don't see any errors, and I see this type signature:
from rtk-github-issues-example.
Hey, this is from cloning the repo and then opening it up in IntelliJ. After clicking into the function IntelliJ does seem to think that the type definition should match
displayRepo(state, action: PayloadAction<CurrentRepo>) {
const { org, repo } = action.payload
state.org = org
state.repo = repo
},
After looking into the types a bit more I believe this actually may be an IntelliJ bug.
declare type CaseReducerActions<CaseReducers extends SliceCaseReducerDefinitions<any, any>> = {
[Type in keyof CaseReducers]: IfIsCaseReducerWithPrepare<CaseReducers[Type], ActionCreatorWithPreparedPayload<PrepareActionForReducer<CaseReducers[Type]>>, IfIsReducerFunctionWithoutAction<CaseReducers[Type], ActionCreatorWithoutPayload, PayloadActionCreator<PayloadForReducer<CaseReducers[Type]>>>>;
};
^^ The above doesn't seem to have any reference to state as an expected parameter, although the types are quite hard to parse at first glance :).
from rtk-github-issues-example.
The above doesn't seem to have any reference to state as an expected parameter, although the types are quite hard to parse at first glance :).
Hah, no kidding :) I'm the maintainer, and I barely understand them! :) I'm grateful that there's some TS experts in the Redux community who have been able to put those together for us.
The action creators definitely do not have any references to the state, either as an argument or a related type. They do reuse the type of the action
argument for the reducer. For this example, since action
is a PayloadAction<CurrentRepo>
, the action creator knows that it should return {type: "issuesDisplay/displayRepo, payload: CurrentRepo}
. It also will have a signature of (payload: CurrentRepo) => PayloadAction<CurrentRepo>
.
from rtk-github-issues-example.
FWIW, I just opened up that same project in WebStorm 2019.1, and the type appears correct there too: waitasec what is that?
No. No, there's definitely not supposed to be a state
argument for displayRepo
. Wut.
I wonder if it's somehow mixing up the action creators and the reducers? Especially since it's labeling the arguments (state, action)
, and not (payload)
like the action creator should have.
from rtk-github-issues-example.
Hmm yes looks like a Jetbrains bug... sigh I don’t think they use LSP for typescript. Thank you for looking into this one! I may open an issue in their issue tracker and reference this issue.
from rtk-github-issues-example.
Yeah, I was just about to do that, actually :)
from rtk-github-issues-example.
Went ahead and filed https://youtrack.jetbrains.com/issue/WEB-42559 .
I'll go ahead and close the issue, since this doesn't appear to be a problem in RTK itself. Thanks for reporting it, though!
I just vote for the request on youtrack.
from rtk-github-issues-example.
Related Issues (9)
- Stateless reducers HOT 1
- Fresh install fails to compile HOT 2
- Cycle dependency HOT 1
- Add tests to the repo HOT 1
- Jest version dependency issue HOT 4
- After run project, dist folder generated in every folder , what tsconfig.json change requires
- Failed to compile. HOT 1
- [Question] Why use Interfaces instead of Types 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 rtk-github-issues-example.