Skip to content

feat: support narrowing by deep object keys in NarrowPartial#1667

Open
ethanresnick wants to merge 1 commit intokysely-org:masterfrom
ethanresnick:deep-narrow
Open

feat: support narrowing by deep object keys in NarrowPartial#1667
ethanresnick wants to merge 1 commit intokysely-org:masterfrom
ethanresnick:deep-narrow

Conversation

@ethanresnick
Copy link
Contributor

Reopening #1526 , but will fix the tests.

Copilot AI review requested due to automatic review settings December 30, 2025 19:25
@vercel
Copy link

vercel bot commented Dec 30, 2025

@ethanresnick is attempting to deploy a commit to the Kysely Team Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

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

This PR adds support for narrowing by deep object keys in the NarrowPartial type utility, enabling more powerful type narrowing capabilities for nested structures like discriminated unions within JSON columns.

Key Changes:

  • Enhanced NarrowPartial type to recursively narrow nested object properties
  • Added comprehensive test coverage for discriminated union narrowing
  • Added missing type assertion for existing test case r15

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/util/type-utils.ts Refactored NarrowPartial to support recursive narrowing of nested objects through intersection with recursive NarrowPartial calls
test/typings/test-d/select.test-d.ts Added test for narrowing discriminated unions at deep object levels and added missing expectType assertion for r15
test/typings/shared.d.ts Added discriminatedUnionProfile field to test data with a discriminated union type for testing the new narrowing capability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ethanresnick
Copy link
Contributor Author

@igalklebanov This should be ready to go now, I think 🤞

@ethanresnick ethanresnick force-pushed the deep-narrow branch 3 times, most recently from f584f6c to 472ab98 Compare December 30, 2025 20:02
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