Skip to content

Conversation

@THE-Amrit-mahto-05
Copy link

@THE-Amrit-mahto-05 THE-Amrit-mahto-05 commented Nov 19, 2025

Correct tsd tests for conn.bulkWrite so that accessing validationErrors on
the result is properly flagged as a type error by TypeScript. Previously,
TypeScript did not catch this without a cast, which could mislead developers
into thinking validationErrors exists directly on ClientBulkWriteResult.

Problem

TSD tests did not fail when trying to access `res3.validationErrors` directly.
This could cause developers to assume the property exists on the bulkWrite result,
which is incorrect.

Changes

- Added `expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors);`
  to properly assert the type error.
- Updated the test file `test/types/connection.test.ts`.

Expected Behavior

TypeScript now fails when trying to access `validationErrors` directly on
`ClientBulkWriteResult`. The property only exists under `res3.mongoose?.validationErrors`.

@vkarpov15 vkarpov15 changed the title fix(tsd): assert validationErrors type error in bulkWrite #15768 test(tsd): assert validationErrors type error in bulkWrite #15768 Nov 25, 2025
@vkarpov15 vkarpov15 added this to the 9.0.1 milestone Nov 25, 2025
@vkarpov15 vkarpov15 merged commit 55b3614 into Automattic:master Nov 25, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants