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

Rewrite Redux core error messages #4055

Merged
merged 4 commits into from
Apr 2, 2021
Merged

Conversation

markerikson
Copy link
Contributor


name: 🐛 Bug fix or new feature
about: Fixing a problem with Redux

This PR:

  • Rewrites most of the Redux core error messages by:
    • Improving runtime typechecks to show a better description of the actual variable type
    • Clarifying wording
    • Adding links to relevant docs pages
  • Overwrites the existing errors.json file with the updated errors, since none of our errors have been released yet
  • Turns on CodeSandbox-CI
  • Updates the error extraction script to ignore a Babel Runtime-specific error message

- Added miniature port of `kindOf` for better `typeof` descriptions
- Used `kindOf` for all runtime type check errors
- Inlined "slice reducer returned undefined" error message
- Rewrote "actions must be plain objects" error message to show the
  actual variable type and added tests
- Reworded a bunch of error messages
- Added some additional docs links
- Updated tests that check error messages
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 2, 2021

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 c83b014:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration

@markerikson markerikson changed the title Exclude Babel Runtime error from our own outputFeature/update error messages Rewrite Redux core error messages Apr 2, 2021
@github-actions
Copy link

github-actions bot commented Apr 2, 2021

Size Change: +363 B (4%)

Total Size: 8.58 kB

Filename Size Change
dist/redux.js 6.87 kB +501 B (7%) 🔍
dist/redux.min.js 1.71 kB -138 B (8%)

compressed-size-action

@netlify
Copy link

netlify bot commented Apr 2, 2021

Deploy preview for redux-docs ready!

Built with commit c83b014

https://deploy-preview-4055--redux-docs.netlify.app

errors.json Outdated
"10": "Expected the nextReducer to be a function. Instead, received: '",
"11": "Expected the observer to be an object. Instead, received: ''",
"12": "The slice reducer for key \"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.",
"13": "The slice reducer for key \"\" returned undefined when probed with a random type. Don't try to handle or other actions in \"redux/*\" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't try to handle or other actions in "redux/*" namespace.

Is this missing a char or '' to get replaced that I'm not seeing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a template literal interpolation there:

`Don't try to handle ${ActionTypes.INIT} or other actions

and that doesn't get included in the extracted message.

I'll add single quotes around it, though.

src/createStore.ts Outdated Show resolved Hide resolved
@markerikson markerikson force-pushed the feature/update-error-messages branch from ed6b5cc to c83b014 Compare April 2, 2021 19:43
@markerikson
Copy link
Contributor Author

Going in! Next up, porting this whole set of changes to 4.x

@markerikson markerikson merged commit d794c56 into master Apr 2, 2021
@markerikson markerikson deleted the feature/update-error-messages branch April 2, 2021 19:46
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
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.

2 participants