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(types): improve the isArray return type for unknown input type #72

Merged
merged 4 commits into from
Jul 4, 2024

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented Jul 3, 2024

Tip

The owner of this PR can publish a preview release by commenting /publish in this PR. Afterwards, anyone can try it out by running pnpm add radashi@pr<PR_NUMBER>.

Summary

This PR adds “type tests” for isArray, showcasing its utility. See the tests/typed/isArray.test-d.ts file. Notably, our isArray utility actually works with readonly arrays, while Array.isArray does not.

In addition, it improves the return type when the input value is typed unknown. It now returns a mutable array type, instead of a readonly one. I believe this new behavior is the most common expectation of how it should work.

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed

Does this PR introduce a breaking change?

No

@aleclarson aleclarson force-pushed the fix/isArray-return-type branch from 9b69d1d to 18339dd Compare July 3, 2024 22:14
@aleclarson aleclarson force-pushed the fix/isArray-return-type branch from c2e51dd to 397d834 Compare July 3, 2024 22:29
@aleclarson aleclarson changed the title fix(types): improved isArray return type for unknown input fix(types): improve the isArray return type for unknown input type Jul 4, 2024
@aleclarson aleclarson merged commit ef14440 into main Jul 4, 2024
4 checks passed
@aleclarson aleclarson deleted the fix/isArray-return-type branch July 4, 2024 00:18
Copy link

github-actions bot commented Jul 4, 2024

A new beta version 12.2.0-beta.6bdfb09 has been published to NPM. 🚀

To install:

The radashi@beta tag also includes this PR.

See the changes

@aleclarson aleclarson added upstream fix Fixes a bug that existed in Radash and removed upstream fix Fixes a bug that existed in Radash labels Jul 9, 2024
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.

1 participant