feat: array-length array-min-length incorporate union types#68
Conversation
📝 WalkthroughWalkthroughThis PR updates ChangesArray assertion type-narrowing widening
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/assert/array-length/array-length.test.ts (1)
314-350: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting shared test interfaces.
The
PolicyStatementandPolicyDocumentinterfaces are defined identically in four test blocks acrossarray-length.test.tsandarray-min-length.test.ts. Extracting them to a shared test fixture would reduce duplication and make it easier to update the test shapes consistently.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/assert/array-length/array-length.test.ts` around lines 314 - 350, The test blocks in array-length.test.ts and array-min-length.test.ts repeat the same PolicyStatement and PolicyDocument interface definitions, so extract those shared types into a common test fixture and reuse them in the affected tests. Update the relevant assertions around assertObjectMatches and arrayOfLength/arrayMinLength to import or reference the shared interfaces, keeping the existing type-narrowing checks unchanged while removing the duplicated local declarations.src/assert/array-length/array-length.type.ts (1)
15-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting shared array-branch helpers.
ArrayBranchOf,ArrayMatchElement, andArrayMatchBranchare identical inarray-length.type.tsandarray-min-length.type.ts. Duplicating these type utilities risks divergence over time. Consider extracting them to a shared module (e.g.,src/assert/array-branch.type.ts) and importing from both.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/assert/array-length/array-length.type.ts` around lines 15 - 23, Extract the shared array-branch type helpers used by ArrayBranchOf, ArrayMatchElement, and ArrayMatchBranch into a single reusable module so array-length.type.ts and array-min-length.type.ts both import the same definitions. Keep the existing type names and behavior intact, but move the duplicated utility types into a shared file (such as a common array-branch type module) and update both assertion type files to reference that shared source.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/assert/array-length/array-length.test.ts`:
- Around line 314-350: The test blocks in array-length.test.ts and
array-min-length.test.ts repeat the same PolicyStatement and PolicyDocument
interface definitions, so extract those shared types into a common test fixture
and reuse them in the affected tests. Update the relevant assertions around
assertObjectMatches and arrayOfLength/arrayMinLength to import or reference the
shared interfaces, keeping the existing type-narrowing checks unchanged while
removing the duplicated local declarations.
In `@src/assert/array-length/array-length.type.ts`:
- Around line 15-23: Extract the shared array-branch type helpers used by
ArrayBranchOf, ArrayMatchElement, and ArrayMatchBranch into a single reusable
module so array-length.type.ts and array-min-length.type.ts both import the same
definitions. Keep the existing type names and behavior intact, but move the
duplicated utility types into a shared file (such as a common array-branch type
module) and update both assertion type files to reference that shared source.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9f6d9fad-c6cd-4cec-ae11-39703286ec5c
📒 Files selected for processing (6)
src/assert/array-length/array-length.assert.tssrc/assert/array-length/array-length.test.tssrc/assert/array-length/array-length.type.tssrc/assert/array-min-length/array-min-length.assert.tssrc/assert/array-min-length/array-min-length.test.tssrc/assert/array-min-length/array-min-length.type.ts
Summary by CodeRabbit