Skip to content

Default export of the module has or is using private name type error when using latest alpha + declaration: true #3455

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

Closed
vidarc opened this issue May 18, 2023 · 3 comments
Milestone

Comments

@vidarc
Copy link

vidarc commented May 18, 2023

import { createSlice } from "@reduxjs/toolkit";

export default createSlice({
  name: "hello",
  initialState: {},
  reducers: (create) => ({
    somePreparedReducer: create.preparedReducer(
      (state: string) => {
        return { payload: { state } };
      },
      (state, action) => {
        state = { something: action.payload };
      }
    ),
  }),
});

with a tsconfig of

{
  "compilerOptions": {
    "declaration": true
  }
}

produces the following two errors

Default export of the module has or is using private name 'ReducerType'.ts(4082)
Default export of the module has or is using private name 'reducerDefinitionType'.ts(4082)

With declaration set to false, the error goes away, but that isn't workable since I am writing a library.

@markerikson
Copy link
Collaborator

Can you put together a repo that shows this happening?

@markerikson markerikson added this to the 2.0 milestone May 18, 2023
@markerikson
Copy link
Collaborator

btw as a side note, state = { something: action.payload }; is a no-op and won't update anything:

https://redux-toolkit.js.org/usage/immer-reducers#resetting-and-replacing-state

@vidarc
Copy link
Author

vidarc commented May 18, 2023

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

2 participants