Romano Zumbé
Romano Zumbé

Reputation: 8099

Typescript compiler error when using redux toolkit

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?

Upvotes: 1

Views: 2155

Answers (2)

Dalila Balic
Dalila Balic

Reputation: 11

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.

Upvotes: 1

phry
phry

Reputation: 44296

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

Upvotes: 3

Related Questions