1

I'm currently trying to setup my first react project using redux and run in a compiler error right from the start.

I installed redux and redux toolkit like this:

npm install @reduxjs/toolkit react-redux

Then I added a store.ts file with this content

import { configureStore } from '@reduxjs/toolkit'

export default configureStore({
  reducer: {}
})

When I try to compile the project I get the following error message:

[09:54:12] Error - [tsc] ../node_modules/@reduxjs/toolkit/dist/createSlice.d.ts(128,125): error TS1005: '?' expected. [09:54:12] Error - [tsc] ../node_modules/@reduxjs/toolkit/dist/createSlice.d.ts(128,154): error TS1005: ';' expected. [09:54:12] Error - 'tsc' sub task errored after 8

My typscript version is 3.9.10

Any Ideas what could be causing this?

2
  • maybe you should pass a reducer to it Commented Nov 23, 2022 at 9:06
  • thats not the problem. Even if the file has only the import I get that error Commented Nov 23, 2022 at 9:24

2 Answers 2

3

That is an extremely outdated version of TypeScript. Redux Toolkit usually supports the last 5 minor versions of TypeScript at the release of the RTK version - at the moment that would be TS>=4.4

Sign up to request clarification or add additional context in comments.

3 Comments

That absolutely makes sense and I thought I would be using a recent version (didn't check it though). Somehow node doesn't update the used typescript version. In the package.json i have the entry "typescript": "^4.9.3" under devDependencies but it still uses version 3.9.10. I'm running the project with gulp
For installing packages, you would be using a package manager like npm, yarn or pnpm. I don't think that's gulps job.
Yes, thats not what I meant. I installed everything with npm. I tried reinstalling and upgrading. But as soon as I run the project with gulp it uses the old tsc version. I thought it might have something to do with gulp
1

I had the same issue, and while I also think it has to do with my app using an older version of TypeScript (unfortunately upgrading to a later version was not an option, it broke too much stuff), what worked for me was just going down to version 1.8.6 of redux/toolkit. Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.