Skip to content

ConditionalPick: Fix returning {} instead of never when no keys match#1359

Merged
sindresorhus merged 3 commits intosindresorhus:mainfrom
derodero24:fix/conditional-pick-empty-object
Feb 9, 2026
Merged

ConditionalPick: Fix returning {} instead of never when no keys match#1359
sindresorhus merged 3 commits intosindresorhus:mainfrom
derodero24:fix/conditional-pick-empty-object

Conversation

@derodero24
Copy link
Contributor

Fixes #1197

Summary

  • When no keys match the given Condition, ConditionalPick previously returned Pick<Base, never> which resolves to {} (empty object type). This allowed any properties to be assigned without type errors.
  • Now it checks if ConditionalKeys returns never using IsNever, and returns never in that case.
  • Added test cases to verify the never return behavior.

Note

The same issue exists in ConditionalPickDeep — tracked separately in #1358.

@derodero24 derodero24 force-pushed the fix/conditional-pick-empty-object branch from 8ffc5eb to f698eb9 Compare February 9, 2026 11:31
@sindresorhus sindresorhus merged commit 3995003 into sindresorhus:main Feb 9, 2026
7 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.

Bug ConditionalPick

3 participants