-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Lodash: Refactor away from _.isString()
#42268
Conversation
Size Change: -17 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the Lodash's _.toString()
method also returns true
when the input is an instance of the String
constructor.
_.isString( new String('123') ) === true;
typeof new String('123') === false;
Not that I think it matters in any of our usage here though 👍
Yes, it does, and thanks for bringing that up! I actually intentionally don't want us to support this scenario, because with |
What?
This PR removes the
_.isString()
usage completely and deprecates the function.Why?
Lodash is known to unnecessarily inflate the bundle size of packages, and in most cases, it can be replaced with native language functionality. See these for more information and rationale:
@wordpress/api-fetch
package haslodash
as a dependency #39495How?
We're replacing it with the safe replacement
typeof === 'string'
ortypeof !== 'string'
, depending on the original logic.Testing Instructions