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

fix: Default export of the module has or is using private name type error when using latest alpha/beta #3605

Merged

Conversation

eric-crowell
Copy link
Contributor

Resolves #3455
Version: 2.0.0-beta.0

The reducerDefinitionType symbol type causes TypeScript issues for consumers of createSlice who have the following included in their tsconfig.json settings:

{
  "compilerOptions": {
    "moduleResolution": "Node16",
    "declaration": true,
  }
}

The TypeScript error appears as...

Exported variable 'X' has or is using name 'reducerDefinitionType' from external module "<path>/node_modules/@reduxjs/toolkit/dist/createSlice" but cannot be named.

Simply ensuring that reducerDefinitionType is exported and publicly accessible does not remove the error (could be an issue with the TypeScript compiler?). Hopefully someone knows how to correctly export this unique symbol or confirm that it is impossible.

Right now, the fix uses the underscore (_) prefix naming convention for the reducerDefinitionType to avoid symbols (although certainly not as unique as what I think is preferred).

Maybe having a separate object that tracks the reducer definition types on a slice can work better?

PR additionally resolves other "not portable" TypeScript errors by exporting the needed types.

Hope this helps you guys.

@codesandbox
Copy link

codesandbox bot commented Jul 19, 2023

This branch is running in CodeSandbox. Use the links below to review this PR faster.


CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders | Preview

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0a19894:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

@netlify
Copy link

netlify bot commented Jul 19, 2023

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 0a19894
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/64b7efd719d12d00088e95a4
😎 Deploy Preview https://deploy-preview-3605--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@markerikson markerikson merged commit be5436d into reduxjs:v2.0-integration Aug 26, 2023
22 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants