-
-
Couldn't load subscription status.
- Fork 21
Fix type support for readonly arrays #40
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
Fixes TypeScript type support for readonly arrays by updating the type definition to handle ReadonlyArray<any> instead of just Array<any> and improves array element type access.
- Updated the
Matchestype definition to support readonly arrays - Changed array element access from
Check[keyof Check]toCheck[number]for better type inference - Added comprehensive test coverage for both mutable and readonly array scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/index.js | Updated TypeScript type definition to support readonly arrays and improved array element access |
| index.test-d.ts | Added test cases to verify type behavior with both mutable and readonly arrays |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| * @typedef {( | ||
| * Check extends Array<any> | ||
| * ? MatchesOne<Value, Check[keyof Check]> | ||
| * Check extends ReadonlyArray<any> |
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.
ReadonlyArray also covers Array already.
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.
Really? It didn’t for me. I believe i played around with it and it did not work 🤔
Maybe my playing around was with this Matches type itself, not with visit? 🤔
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.
@wooorm The big difference is actually Check[keyof Check]> vs Check[number]>.
Initial checklist
Description of changes
close #39