Skip to content

ConditionalPickDeep returns {} instead of never when no keys match #1358

@derodero24

Description

@derodero24

Same issue as #1197 but for ConditionalPickDeep.

When no keys match the given condition, ConditionalPickDeep returns {} instead of never:

import type {ConditionalPickDeep} from 'type-fest';

type Example = {
  a: string;
  b: string | boolean;
  c: {
    d: string;
    e: {
      f?: string;
      g?: boolean;
    };
    j: boolean;
  };
};

type NumberPick = ConditionalPickDeep<Example, number>;
//   ^? {} — should be `never`

const test: NumberPick = {
  anything: 'is accepted', // No error, but should be
};

ConditionalPick is being fixed in #1197. ConditionalPickDeep has the same behavior and should be addressed separately since it uses a different internal implementation (ConditionalExcept-based).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions