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

ReducerWithInitialState is not portlable according to TS #4108

Closed
krutoo opened this issue Jan 22, 2024 · 6 comments
Closed

ReducerWithInitialState is not portlable according to TS #4108

krutoo opened this issue Jan 22, 2024 · 6 comments

Comments

@krutoo
Copy link

krutoo commented Jan 22, 2024

Hi, in my project i use toolkit 2.0.0 and i have type check build during emit declaration files only with isolatedModules: true option in tsconfig:

{
  "compilerOptions": {
    "target": "ES2021",
    "moduleResolution": "Bundler",
    "baseUrl": ".",
    "jsx": "react-jsx",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "noUncheckedIndexedAccess": true,
    "outDir": "dist/types",
    "declaration": true,
    "sourceMap": true,
    "emitDeclarationOnly": true,
    "isolatedModules": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "*.test.*", "**/__test__/*"]
}

i have error:

src/internal/core/redux/index.ts:64:14 - error TS2742: The inferred type of 'reducer' cannot be named without a reference to '../../../../node_modules/@reduxjs/toolkit/dist/createReducer'. This is likely not portable. A type annotation is necessary.

Can we add export of ReducerWithInitialState from entry point of package?

@krutoo
Copy link
Author

krutoo commented Jan 22, 2024

i have reducer like:

export const reducer = createReducer({/* ... */}, () => {/* ... */})

@shermify
Copy link

It's a known issue when declaration=true with ES modules
#4066

aryaemami59 added a commit to aryaemami59/redux-toolkit that referenced this issue Jun 8, 2024
- This should serve as a partial fix for reduxjs#3962, reduxjs#4448, reduxjs#3983, reduxjs#4066, reduxjs#4108, reduxjs#4401
- Here is the list of the problematic (now exported) types:
  From `@reduxjs/toolkit`:
  - `CombinedSliceReducer`
  - `CaseReducerDefinition`
  - `Id` renamed to `TSHelpersId`
  - `UncheckedIndexedAccess`
  - `ReducerWithInitialState`
  - `CaseReducerDefinition`
  - `Id` renamed to `TSHelpersId`
  - `UncheckedIndexedAccess`
  - `ReducerWithInitialState`
  From `@reduxjs/toolkit/query/react`:
  - `UseLazyQuery`
  - `UseQuery`
  - `QueryHooks`
@aryaemami59
Copy link
Contributor

aryaemami59 commented Jul 9, 2024

Can you run this command and try again to see if it fixes the issue:

npm install https://pkg.csb.dev/reduxjs/redux-toolkit/commit/06a30ee4/@reduxjs/toolkit

@markerikson
Copy link
Collaborator

Fixed in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.2.7 !

@krutoo
Copy link
Author

krutoo commented Jul 28, 2024

@markerikson thanks a lot, (looks like release title is 2.2.6 for tag 2.2.7)

@EskiMojo14
Copy link
Collaborator

@krutoo fixed, thanks

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

5 participants