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: isObject utils fn should return only boolean value #4756

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

tiendn
Copy link
Contributor

@tiendn tiendn commented Oct 25, 2024

Description

When isObject pass with param null/undefined it returns null/undefined

We should strict return boolean value

Drive-by changes

export function isObject(item: any): boolean {
- return item && typeof item === 'object' && !Array.isArray(item);
+ return !!item && typeof item === 'object' && !Array.isArray(item);
}

Related issues

Backward compatibility

Testing

Has updated with test object.test.ts

Copy link

changeset-bot bot commented Oct 25, 2024

🦋 Changeset detected

Latest commit: a9c0b32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@hyperlane-xyz/utils Patch
@hyperlane-xyz/core Patch
@hyperlane-xyz/cli Patch
@hyperlane-xyz/infra Patch
@hyperlane-xyz/sdk Patch
@hyperlane-xyz/widgets Patch
@hyperlane-xyz/helloworld Patch
@hyperlane-xyz/ccip-server Patch
@hyperlane-xyz/github-proxy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

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

Nice improvement!

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.97%. Comparing base (a42616f) to head (a9c0b32).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4756   +/-   ##
=======================================
  Coverage   73.97%   73.97%           
=======================================
  Files         101      101           
  Lines        1460     1460           
  Branches      191      191           
=======================================
  Hits         1080     1080           
  Misses        359      359           
  Partials       21       21           
Components Coverage Δ
core 84.61% <ø> (ø)
hooks 75.71% <ø> (ø)
isms 77.58% <ø> (ø)
token 89.01% <ø> (ø)
middlewares 77.39% <ø> (ø)

@jmrossy jmrossy added this pull request to the merge queue Oct 25, 2024
Merged via the queue into hyperlane-xyz:main with commit a36fc5f Oct 25, 2024
28 of 32 checks passed
@tiendn tiendn deleted the fix/is-object-return-bool branch October 25, 2024 15:39
paulbalaji pushed a commit that referenced this pull request Oct 29, 2024
### Description
When `isObject` pass with param `null/undefined` it returns
`null/undefined`

We should strict return boolean value
<!--
What's included in this PR?
-->

### Drive-by changes
```diff
export function isObject(item: any): boolean {
- return item && typeof item === 'object' && !Array.isArray(item);
+ return !!item && typeof item === 'object' && !Array.isArray(item);
}
```
<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing
Has updated with test `object.test.ts`
<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
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