Repository navigation
fix: type the validated value as unknown - #243
alexander-akait wants to merge 2 commits into
Conversation
A validator checks a value of a type not yet known, so `validate`'s options and a precompiled check's value are `unknown` rather than `object | object[]` and `any`. Callers no longer cast to `object` before validating.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #243 +/- ##
=======================================
Coverage 97.23% 97.23%
=======================================
Files 13 13
Lines 1231 1231
Branches 476 476
=======================================
Hits 1197 1197
Misses 32 32
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f466fd2c-cdfd-430c-be01-c8ec5320de56
Files selected for processing: 3-
.changeset/validate-unknown-options.mddeclarations/validate.d.tssrc/validate.js
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
-
A check a caller types by its own options, `(value: MyOptions) => boolean`, is not assignable to `(value: unknown) => boolean`, so keep the value `any` there. Only `validate`'s options become `unknown`, which accepts every value it did.
|
Closing: neither form is worth it.
So Generated by Claude Code |
Summary
A validator checks a value whose type isn't known yet, but
validatedeclared it asobject[] | objectand a precompiled check tookany. Callers had to cast their input toobjectbefore validating it. In webpack, that cast is one of the escape hatches its type coverage counts (webpack/webpack#23047).The runtime is unchanged.
validatealready handles an array and any other value throughArray.isArray, and the schema decides what is valid.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
No; only the declared types change. All 1046 existing tests pass, and
npm run lintpasses. The declarations were regenerated withnpm run build:types.Does this PR introduce a breaking change?
No. The parameter now accepts anything it accepted before, and a precompiled check typed
(value: unknown) => booleanis still callable with any value.If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Claude Code found the cast while reducing escape hatches in webpack, wrote the change, and checked it with
npm run lint, the test suite and the regenerated declarations. The author reviewed it.Generated by Claude Code
Summary by CodeRabbit
validateoptions parameter is now typed asunknown, replacing the previous object-or-array type. This broadens the values accepted by the public type declaration; runtime behavior is unchanged.