Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented Oct 20, 2025

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything or linked relevant results below
  • I made sure the docs are up to date
  • I included tests (or that’s not needed)

Description of changes

close #39

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Oct 20, 2025
Copy link

Copilot AI left a 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 Matches type definition to support readonly arrays
  • Changed array element access from Check[keyof Check] to Check[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>
Copy link
Member Author

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.

Copy link
Member

@wooorm wooorm Oct 22, 2025

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? 🤔

Copy link
Member Author

@JounQin JounQin Oct 23, 2025

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]>.

TypeScript Playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤞 phase/open Post is being triaged manually

3 participants