Prepare 2.0.1#81
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a small "narrowing in if/else" describe block to each is* type-guard spec file under helpers/type/, using expectTypeOf from Vitest to verify that the predicates narrow values correctly inside truthy branches. It complements the existing property-based and contract test suites without modifying any production code.
Changes:
- Imports
expectTypeOffromvitestin 33*.spec.tsfiles. - Adds a uniform
describe('<guard> — narrowing in if/else', …)block per file asserting the narrowed type and a runtime sanity check. - Adds named type imports (
type Falsy,type Primitive) where needed for the assertions.
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| helpers/type/isArray.spec.ts | Asserts narrowing to unknown[] |
| helpers/type/isArrayBuffer.spec.ts | Asserts narrowing to ArrayBuffer |
| helpers/type/isAsyncFunction.spec.ts | Asserts narrowing to (...args: unknown[]) => Promise<unknown> |
| helpers/type/isBigInt.spec.ts | Asserts narrowing to bigint |
| helpers/type/isBlob.spec.ts | Asserts narrowing to Blob |
| helpers/type/isBoolean.spec.ts | Asserts narrowing to boolean |
| helpers/type/isBuffer.spec.ts | Asserts narrowing to Buffer |
| helpers/type/isDate.spec.ts | Asserts narrowing to Date |
| helpers/type/isDefined.spec.ts | Asserts removal of null/undefined from union |
| helpers/type/isError.spec.ts | Asserts narrowing to Error |
| helpers/type/isFalsy.spec.ts | Imports Falsy; asserts narrowing to Falsy |
| helpers/type/isFormData.spec.ts | Asserts narrowing to FormData |
| helpers/type/isFunction.spec.ts | Asserts narrowing to Function (with ban-types disable) |
| helpers/type/isIterable.spec.ts | Asserts narrowing to Iterable<unknown> |
| helpers/type/isMap.spec.ts | Asserts narrowing to Map<unknown, unknown> |
| helpers/type/isNegativeNumber.spec.ts | Asserts narrowing to number |
| helpers/type/isNonEmptyArray.spec.ts | Asserts narrowing to [unknown, ...unknown[]] |
| helpers/type/isNonEmptyString.spec.ts | Asserts narrowing to string |
| helpers/type/isNull.spec.ts | Asserts narrowing to null |
| helpers/type/isNullish.spec.ts | Asserts narrowing to null | undefined |
| helpers/type/isNumber.spec.ts | Asserts narrowing to number |
| helpers/type/isPlainObject.spec.ts | Asserts narrowing to Record<string, unknown> |
| helpers/type/isPositiveNumber.spec.ts | Asserts narrowing to number |
| helpers/type/isPrimitive.spec.ts | Imports Primitive; asserts narrowing to Primitive |
| helpers/type/isPromise.spec.ts | Asserts narrowing to PromiseLike<unknown> |
| helpers/type/isRegExp.spec.ts | Asserts narrowing to RegExp |
| helpers/type/isString.spec.ts | Asserts narrowing to string |
| helpers/type/isSymbol.spec.ts | Asserts narrowing to symbol |
| helpers/type/isTemporalDuration.spec.ts | Asserts narrowing to Temporal.Duration |
| helpers/type/isTemporalInstant.spec.ts | Asserts narrowing to Temporal.Instant |
| helpers/type/isTemporalPlainDate.spec.ts | Asserts narrowing to Temporal.PlainDate |
| helpers/type/isTemporalPlainDateTime.spec.ts | Asserts narrowing to Temporal.PlainDateTime |
| helpers/type/isTemporalPlainTime.spec.ts | Asserts narrowing to Temporal.PlainTime |
| helpers/type/isTemporalZonedDateTime.spec.ts | Asserts narrowing to Temporal.ZonedDateTime |
| helpers/type/isTimestamp.spec.ts | Asserts narrowing to number |
| helpers/type/isTruthy.spec.ts | Asserts removal of Falsy from union |
| helpers/type/isUndefined.spec.ts | Asserts narrowing to undefined |
| helpers/type/isValidDate.spec.ts | Asserts narrowing to Date |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- add tests for isBigInt - add tests for isBlob - add tests for isBoolean - add tests for isBuffer - add tests for isDate - add tests for isDefined - add tests for isError - add tests for isFalsy - add tests for isFormData - add tests for isFunction - add tests for isIterable - add tests for isMap - add tests for isNegativeNumber - add tests for isNonEmptyArray - add tests for isNonEmptyString - add tests for isNull - add tests for isNullish - add tests for isNumber - add tests for isPlainObject - add tests for isPositiveNumber - add tests for isPrimitive - add tests for isPromise - add tests for isRegExp - add tests for isString - add tests for isSymbol - add tests for isTemporalDuration - add tests for isTemporalInstant - add tests for isTemporalPlainDate - add tests for isTemporalPlainDateTime - add tests for isTemporalPlainTime - add tests for isTemporalZonedDateTime - add tests for isTimestamp - add tests for isTruthy - add tests for isUndefined - add tests for isValidDate
- update return type to act as a type guard - add examples for type narrowing in else branch
- add node helper category - update contributing and readme files - create config for node utilities
- implement isBuffer function to check Node.js Buffer instances - add property-based and contract tests for isBuffer - create example usage for isBuffer in Node.js context
The coherency check requires that peer dep versions in built packages match the root package.json exactly. Config-declared peer deps were using their own version range (>=22) instead of the root's (^25.9.1). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
isEmpty: extend type predicate to ReadonlyMap<never,never> | ReadonlySet<never> so Map/Set narrowing works in the true branch. Plain objects remain excluded (no precise TypeScript representation for "empty object"). Peer deps: coherency check now skips peerDependencies — they are consumer-facing semver constraints (e.g. @types/node >=22 = oldest LTS) intentionally different from root dev-tooling versions. prepareCategoryPackageJson uses config.json versions as-is instead of overriding with the root version. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please include a summary of what this PR does and why it's needed.
Type of Change
Related Issues
Closes #(issue number)
How Has This Been Tested?
Describe the tests you ran and how to reproduce them:
Checklist
Screenshots (if applicable)
Add screenshots for UI changes.
Additional Context
Add any other context about the PR here.