Repository: remeda/remeda
Pull request #1129 (2025-06-30 10:37:57)

fix(pick): Add support for unions and unbounded records
Fixes: #1128

bolt-new-by-stackblitz[bot]: <a href="https://stackblitz.com/~/github.com/remeda/remeda/pull/1129"><img src="https://developer.stackblitz.com/img/review_pr_small.svg" alt="Review PR in StackBlitz Codeflow" align="left" width="103" height="20" target="_blank"></a> _Run & review this pull request in [StackBlitz Codeflow](https://stackblitz.com/~/github.com/remeda/remeda/pull/1129)._

pkg-pr-new[bot]: 
[@remeda/stackblitz-template](https://pkg.pr.new/template/92b32a0c-63c6-4aa9-8884-a99737f53991)


```
npm i https://pkg.pr.new/remeda@1129
```


_commit: <a href="https://github.com/remeda/remeda/runs/45193077239"><code>56f261c</code></a>_


Patch:
diff --git a/packages/remeda/src/internal/types/BoundedPartial.ts b/packages/remeda/src/internal/types/BoundedPartial.ts
index 4cf24e2..37187c9 100644
--- a/packages/remeda/src/internal/types/BoundedPartial.ts
+++ b/packages/remeda/src/internal/types/BoundedPartial.ts
@@ -1,4 +1,5 @@
-import type { IfBoundedRecord } from "./IfBoundedRecord";
+import type { If } from "./If";
+import type { IsBoundedRecord } from "./IsBoundedRecord";
 
 /**
  * Records with an unbounded set of keys have different semantics to those with
@@ -9,4 +10,4 @@ import type { IfBoundedRecord } from "./IfBoundedRecord";
  *    BoundedPartial<{ a: number }>; //=> { a?: number }
  *    BoundedPartial<Record<string, number>>; //=> Record<string, number>
  */
-export type BoundedPartial<T> = IfBoundedRecord<T, Partial<T>, T>;
+export type BoundedPartial<T> = If<IsBoundedRecord<T>, Partial<T>, T>;
diff --git a/packages/remeda/src/internal/types/If.ts b/packages/remeda/src/internal/types/If.ts
new file mode 100644
index 0000000..b1e7340
--- /dev/null
+++ b/packages/remeda/src/internal/types/If.ts
@@ -0,0 +1,9 @@
+import type { IsNever } from "type-fest";
+
+// TODO [type-fest@>=5] -- This type is shipping in type-fest v5 and standardizes all IfXXX types. We backported it so that we can already use it before v5 is shipped.
+export type If<Type extends boolean, IfBranch, ElseBranch> =
+  IsNever<Type> extends true
+    ? ElseBranch
+    : Type extends true
+      ? IfBranch
+      : ElseBranch;
diff --git a/packages/remeda/src/internal/types/IfBoundedRecord.ts b/packages/remeda/src/internal/types/IfBoundedRecord.ts
deleted file mode 100644
index fb62c3f..0000000
--- a/packages/remeda/src/internal/types/IfBoundedRecord.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import type {
-  KeysOfUnion,
-  IsStringLiteral,
-  IsNumericLiteral,
-  IsSymbolLiteral,
-  Split,
-} from "type-fest";
-
-/**
- * Check if a type is guaranteed to be a bounded record: a record with a finite
- * set of keys.
- *
- * @example
- *     IfBoundedRecord<{ a: 1, 1: "a" }>; //=> true
- *     IfBoundedRecord<Record<string | number, unknown>>; //=> false
- *     IfBoundedRecord<Record<`prefix_${number}`, unknown>>; //=> false
- */
-export type IfBoundedRecord<
-  T,
-  TypeIfBoundedRecord = true,
-  TypeIfUnboundedRecord = false,
-> =
-  IsBoundedKey<KeysOfUnion<T>> extends true
-    ? TypeIfBoundedRecord
-    : TypeIfUnboundedRecord;
-
-/**
- * Checks if a type is a bounded key: a union of bounded strings, numeric
- * literals, or symbol literals.
- */
-type IsBoundedKey<T> =
-  // `extends unknown` is always going to be the case and is used to convert any
-  // union into a [distributive conditional type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
-  T extends unknown
-    ? IsStringLiteral<T> extends true
-      ? IsBoundedString<T>
-      : IsNumericLiteral<T> extends true
-        ? true
-        : IsSymbolLiteral<T>
-    : never;
-
-/**
- * Checks if a type is a bounded string: a type that only has a finite
- * number of strings that are that type.
- *
- * Most relevant for template literals: IsBoundedString<`${1 | 2}_${3 | 4}`> is
- * true, and IsBoundedString<`${1 | 2}_${number}`> is false.
- */
-type IsBoundedString<T> = T extends string
-  ? // (T[number] alone doesn't work because that's just string.)
-    Split<T, "">[number] extends infer U
-    ? // string. Otherwise, we assume it's bounded.
-      [`${number}`] extends [U]
-      ? false
-      : [string] extends [U]
-        ? false
-        : true
-    : false
-  : false;
diff --git a/packages/remeda/src/internal/types/IsBounded.ts b/packages/remeda/src/internal/types/IsBounded.ts
new file mode 100644
index 0000000..6963479
--- /dev/null
+++ b/packages/remeda/src/internal/types/IsBounded.ts
@@ -0,0 +1,48 @@
+import type {
+  IsNumericLiteral,
+  IsStringLiteral,
+  IsSymbolLiteral,
+  Or,
+  Split,
+} from "type-fest";
+
+/**
+ * Checks if a type is a bounded key: a union of bounded strings, numeric
+ * literals, or symbol literals.
+ *
+ * [For an interactive deeper dive and explanation see the following playground](https://www.typescriptlang.org/play/?noUncheckedIndexedAccess=true#code/PTAEBUAsEsGdQE4FMDGB7BATUdQCIAjNAVwDtMlM8AaHAF1EgEN4nQAzaU6OpUWJAzTtQAayQBPWADpQASQZMANrDSIkAR2LRk8HgHJYAKBCg0BAFaoGdNcwBufZUrMi6kJAFtpRuhIAOfABCJOSUoAC8oABKqBiYADwABv7InAAeAPoAJADeeB5KSmh4oAA++ADuGEpUAL5JtHiqnoIwpADmeAB8ANxGJmBQuMjoWDjweGREZBRUtDyMLKBMpDiknNy8-IKuoP5osLDQBEp84lKyCoaDZpbWoOjEtY9opHRMXKCkb3zCoO4vAC0GgfH5AqAAKqkGZhbBRWJjRIpNLQLJ5WB0BBcDoNJotNo4nr9W4AMQwK1IEggAC4IKAkOleOR4AAFJgIOjQZQJcDdUAEakUTZct60AjEGwedaOBACCbfNCKJSVJhSW5Y4hIWQAdQ8a0WuE1fEqfBQq34aoBzAY4AV0E8-iU0BQPCU1P8HK5ylAAApDcZTJptPZlEh3sDQOzOdylLzugBKXwBPhyWByR3O110d3R71xvmRKNe2PxhlM8OYeB2gD8+AkpTpeFIeBJpj14ZWKBQSCOOJW+wQaH8e0BAtCczuVhQtpTAGUUNj-AxzWtw7BiMhrUwGKlh7dGXA6Ho1mPzNPFOQGaQN1uePBwdqjBQUEoOWa3pjQEEAPKQgByAAiACigF0iEsyUP06A3gwsKTlEv4ASBgEANp4KkSAZJkhTFHgAC6-SmKAJEAHo1gM7b6l2PZ9p0A57iO-xjtME7hOe1i0JU1H6D80IoB4KDiJgchhOklAAILdr2sBJLcuDhkwpzhOA86LtAy6PBabzutet4mjaAIpvQoAAFSeNAHSQHQpkCkg4qSisKhoLcMHHBQCDWmaLAGUgd4MJgaC9qQ+gMIeX5fGe9wzrQqgmU8LzKHFBBILcSSQZslBJD4L5vlubkMABSFAaBdLQvBUFGAVoCsZB8JQv+xUoehmHYbhJSEbcJGgORlFDDAegPggWocBSpmmasEjjYOw57EVf4lYBvSgNxLqQKArSrA+hnODN-jwMItzzchoErFueDDqKpDKDQK0wAJCqMkwM66dxO6gEkealo+-zHYt3RyaYm03jsnirFy5pFBIy1xaa+jYIygQztaRpqMgdCbms+gSPoDkMIs6OY-AvH6AAhMmEJpuVbEiZmLpuhIX0+lEaYZk69M5ozJY8tTdV9F1PUUbcervbt7i4MDg3bvjaxg1SWkCLAtC9kjsa6e4hx8O4726MwEKrLcHHI6aG2WdZ3xIOEthLOQZzjnVlLYLVcLqEi8ACJ6CA7u6tCrJgrmrKF6i6W8OB09mrx+a6n7K44azcZ2gLUmD4g7De2rSD4QA).
+ */
+export type IsBounded<T> =
+  // `extends unknown` is always going to be the case and is used to convert any
+  // union into a [distributive conditional type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
+  (
+    T extends unknown
+      ? Or<IsBoundedString<T>, Or<IsNumericLiteral<T>, IsSymbolLiteral<T>>>
+      : never
+  ) extends true
+    ? // When some parts of the union result in `true` and others in `false`
+      // (e.g. `"a" | number`), when we distribute the union we would get
+      // `boolean` as a result (because `true | false` === `boolean`); but the
+      // union as a whole is bounded only if **all** it's parts are bounded
+      // individually.
+      true
+    : false;
+
+/**
+ * Literal strings can be unbounded when they are a template literal which
+ * contains non-literal components (e.g. `prefix_${string}`), this is because
+ * there are an infinite number of possible values that satisfy it.
+ */
+type IsBoundedString<T> = T extends string
+  ? IsStringLiteral<T> extends true
+    ? // T[number] alone doesn't work because that's just string.
+      Split<T, "">[number] extends infer U
+      ? // string. Otherwise, we assume it's bounded.
+        [`${number}`] extends [U]
+        ? false
+        : [string] extends [U]
+          ? false
+          : true
+      : false
+    : false
+  : false;
diff --git a/packages/remeda/src/internal/types/IsBoundedRecord.ts b/packages/remeda/src/internal/types/IsBoundedRecord.ts
new file mode 100644
index 0000000..e6c2802
--- /dev/null
+++ b/packages/remeda/src/internal/types/IsBoundedRecord.ts
@@ -0,0 +1,15 @@
+import type { KeysOfUnion } from "type-fest";
+import type { IsBounded } from "./IsBounded";
+
+/**
+ * Check if a type is guaranteed to be a bounded record: a record with a finite
+ * set of keys.
+ *
+ * See the docs for `IsBounded` to understand more.
+ *
+ * @example
+ *   IsBoundedRecord<{ a: 1, 1: "a" }>; //=> true
+ *   IsBoundedRecord<Record<string | number, unknown>>; //=> false
+ *   IsBoundedRecord<Record<`prefix_${number}`, unknown>>; //=> false
+ */
+export type IsBoundedRecord<T> = IsBounded<KeysOfUnion<T>>;
diff --git a/packages/remeda/src/internal/types/IsUnion.ts b/packages/remeda/src/internal/types/IsUnion.ts
index 8060a07..26d22bd 100644
--- a/packages/remeda/src/internal/types/IsUnion.ts
+++ b/packages/remeda/src/internal/types/IsUnion.ts
@@ -1,6 +1,6 @@
 import type { IsNever } from "type-fest";
 
-// TODO: This type is copied from type-fest because it isn't exported. It's part of the "internal" types. We should check back in a while to see if this type is added to the public offering.
+// TODO [type-fest@>=5]: This type will be exported in v5. We don't need to re-implement and export it here.
 export type IsUnion<T> = InternalIsUnion<T>;
 
 type InternalIsUnion<T, U = T> = (
diff --git a/packages/remeda/src/omitBy.ts b/packages/remeda/src/omitBy.ts
index d9b7bf3..86c6ac9 100644
--- a/packages/remeda/src/omitBy.ts
+++ b/packages/remeda/src/omitBy.ts
@@ -1,7 +1,8 @@
 import type { IfNever, Simplify } from "type-fest";
 import type { EnumerableStringKeyOf } from "./internal/types/EnumerableStringKeyOf";
 import type { EnumerableStringKeyedValueOf } from "./internal/types/EnumerableStringKeyedValueOf";
-import type { IfBoundedRecord } from "./internal/types/IfBoundedRecord";
+import type { If } from "./internal/types/If";
+import type { IsBoundedRecord } from "./internal/types/IsBoundedRecord";
 import type { ReconstructedRecord } from "./internal/types/ReconstructedRecord";
 import { purry } from "./purry";
 
@@ -22,8 +23,8 @@ type PartialEnumerableKeys<T extends object> =
   // union into a [distributive conditional type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
   T extends unknown
     ? Simplify<
-        IfBoundedRecord<
-          T,
+        If<
+          IsBoundedRecord<T>,
           PickSymbolKeys<T> & {
             -readonly [P in keyof T as P extends symbol
               ? never
diff --git a/packages/remeda/src/pick.ts b/packages/remeda/src/pick.ts
index ab102d2..fbaabb4 100644
--- a/packages/remeda/src/pick.ts
+++ b/packages/remeda/src/pick.ts
@@ -1,20 +1,109 @@
-import type { Simplify } from "type-fest";
+import type { EmptyObject, IsNever, KeysOfUnion, Writable } from "type-fest";
+import type { If } from "./internal/types/If";
+import type { IsBounded } from "./internal/types/IsBounded";
+import type { IsBoundedRecord } from "./internal/types/IsBoundedRecord";
+import type { IsUnion } from "./internal/types/IsUnion";
 import type { TupleParts } from "./internal/types/TupleParts";
 import { purry } from "./purry";
 
-type PickFromArray<T, Keys extends ReadonlyArray<keyof T>> = Simplify<
-  // The keys that are in the fixed parts of the Keys array will always be part
-  // of the result.
+type PickFromArray<T, Keys extends ReadonlyArray<KeysOfUnion<T>>> =
+  // Distribute unions for both object types and key arrays.
+  T extends unknown
+    ? Keys extends unknown
+      ? If<
+          // When T is a union (or when Keys is empty) the picked props might
+          // not exist in some of its sub-types, e.g.,
+          //   `pick(... as { a: string } | { b: number }, ['a'])`,
+          // if we simply let the regular "constructive" logic run, the
+          // resulting type would be `{}` which doesn't behave like an empty
+          // object! instead, we want to use a more explicit *empty* type.
+          IsNever<Extract<Keys[number], keyof T>>,
+          EmptyObject,
+          // Remove `readonly` modifiers from picked props since we return a
+          // new, mutable, object. We don't wrap the result with `Simplify` to
+          // flatten it because `Writable` does the same thing implicitly.
+          Writable<
+            If<
+              IsBoundedRecord<T>,
+              PickBoundedFromArray<T, Keys>,
+              PickUnbounded<T, Extract<Keys[number], keyof T>>
+            >
+          >
+        >
+      : never
+    : never;
+
+/**
+ * Bounded records have bounded keys and result in a bounded output. The only
+ * question left is whether to add the prop as-is, or make it optional. This
+ * can be determined by the part of the keys array the prop is defined in, and
+ * the way that element is defined: if the array contains a singular literal
+ * key in either the required prefix or the suffix, we know that prop should be
+ * picked as-is, otherwise, the key might not be present in the keys array so it
+ * can only be picked optionally.
+ */
+type PickBoundedFromArray<T, Keys extends ReadonlyArray<KeysOfUnion<T>>> =
+  // Literal keys in the prefix/suffix are guaranteed present.
   Pick<
     T,
-    TupleParts<Keys>["required"][number] | TupleParts<Keys>["suffix"][number]
+    // When T is a union the keys need to be narrowed to just those that are
+    // keys of the specific sub-type being built
+    Extract<
+      | ItemsByUnion<TupleParts<Keys>["required"]>["singular"]
+      | ItemsByUnion<TupleParts<Keys>["suffix"]>["singular"],
+      keyof T
+    >
   > &
-    // The keys in the optional parts of the Keys array might be part of the
-    // result or not, so we need to make this part of the result partial to
-    // reflect that.
+    // Union keys, optional elements, and rest elements are optional.
     Partial<
-      Pick<T, TupleParts<Keys>["optional"][number] | TupleParts<Keys>["item"]>
+      Pick<
+        T,
+        // When T is a union the keys need to be narrowed to just those that are
+        // keys of the specific sub-type being built.
+        Extract<
+          | ItemsByUnion<TupleParts<Keys>["required"]>["union"]
+          // TODO: the optional part of the keys array will always be empty because its impossible to provide the pick function with a tuple with optional elements; this is because optional elements are always implicitly `undefined` too; which breaks the constraint that all keys are keys of T (`undefined` is not a key of anything). We can lift this restriction by supporting `undefined` in the runtime and relaxing the type constraint to allow it, but this relaxed constraint enables a niche feature (optional tuple elements) at the expense of better type-safety for the more common cases of fixed tuples and arrays. Anyway... if we ever change it, this part of the output type will ensure the output is still correct:
+          | TupleParts<Keys>["optional"][number]
+          | TupleParts<Keys>["item"]
+          | ItemsByUnion<TupleParts<Keys>["suffix"]>["union"],
+          keyof T
+        >
+      >
+    >;
+
+/**
+ * We split the fixed tuple item types into **singular** props (e.g., `"a"`),
+ * and unions of several props (e.g., `"a" | "b"`).
+ *
+ * We assume that T is a fixed tuple (no optional or rest elements), and that
+ * all elements in it are bounded (as defined by `IsBounded`).
+ */
+type ItemsByUnion<T, Singular = never, Union = never> = T extends readonly [
+  infer Head,
+  ...infer Rest,
+]
+  ? If<
+      IsUnion<Head>,
+      ItemsByUnion<Rest, Singular, Union | Head>,
+      ItemsByUnion<Rest, Singular | Head, Union>
     >
+  : { singular: Singular; union: Union };
+
+/**
+ * The built-in `Pick` is weird when it comes to picking bounded keys from
+ * unbounded records. It reconstructs the output object regardless of the shape
+ * of the input: `Pick<Record<string, "world">, "hello">` results in the type
+ * `{ hello: "world" }`, but you'd expect it to be optional because we don't
+ * know if the record contains a `hello` prop or not!
+ *
+ * !Important: We assume T is unbounded and don't test for it!
+ *
+ * See: https://www.typescriptlang.org/play/?#code/PTAEE0HsFcHIBNQFMAeAHJBjALqAGqNpKAEZKigAGA3qABZIA2jkA-AFygBEA7pAE6N4XUAF9KAGlLRcAQ0ayAzgChsATwz5QAXlAAFAJaYA1gB4ASlgHxTi7PwMA7AOZTeAoVwB8bhs0jeANzKIBSgAHqsykA.
+ */
+type PickUnbounded<T, Keys extends keyof T> = If<
+  IsBounded<Keys>,
+  Partial<Pick<T, Keys>>,
+  Pick<T, Keys>
 >;
 
 /**
@@ -29,7 +118,7 @@ type PickFromArray<T, Keys extends ReadonlyArray<keyof T>> = Simplify<
  */
 export function pick<
   T extends object,
-  const Keys extends ReadonlyArray<keyof T>,
+  const Keys extends ReadonlyArray<KeysOfUnion<T>>,
 >(keys: Keys): (data: T) => PickFromArray<T, Keys>;
 
 /**
@@ -45,7 +134,7 @@ export function pick<
  */
 export function pick<
   T extends object,
-  const Keys extends ReadonlyArray<keyof T>,
+  const Keys extends ReadonlyArray<KeysOfUnion<T>>,
 >(data: T, keys: Keys): PickFromArray<T, Keys>;
 
 export function pick(...args: ReadonlyArray<unknown>): unknown {
diff --git a/packages/remeda/src/pickBy.ts b/packages/remeda/src/pickBy.ts
index dd7e963..f9f8fdd 100644
--- a/packages/remeda/src/pickBy.ts
+++ b/packages/remeda/src/pickBy.ts
@@ -1,7 +1,8 @@
 import type { IfNever, Simplify } from "type-fest";
 import type { EnumerableStringKeyOf } from "./internal/types/EnumerableStringKeyOf";
 import type { EnumerableStringKeyedValueOf } from "./internal/types/EnumerableStringKeyedValueOf";
-import type { IfBoundedRecord } from "./internal/types/IfBoundedRecord";
+import type { If } from "./internal/types/If";
+import type { IsBoundedRecord } from "./internal/types/IsBoundedRecord";
 import { purry } from "./purry";
 
 // Because pickBy needs to iterate over all entries of the object, only
@@ -14,8 +15,8 @@ type EnumerableKey<T> = `${T extends number | string ? T : never}`;
 // whole object to a Partial of the input.
 type EnumeratedPartial<T> = T extends unknown
   ? Simplify<
-      IfBoundedRecord<
-        T,
+      If<
+        IsBoundedRecord<T>,
         {
           -readonly [P in keyof T as EnumerableKey<P>]?: Required<T>[P];
         },
@@ -42,8 +43,8 @@ type EnumeratedPartial<T> = T extends unknown
 // optional (as they could have a value that would be filtered out).
 type EnumeratedPartialNarrowed<T, S> = T extends unknown
   ? Simplify<
-      IfBoundedRecord<
-        T,
+      If<
+        IsBoundedRecord<T>,
         ExactProps<T, S> & PartialProps<T, S>,
         // For unbounded records we need to "reconstruct" the record and narrow
         // the value types. Similar to the non-narrowed case, we need to also


Test patch:
diff --git a/packages/remeda/src/internal/types/IfBoundedRecord.test-d.ts b/packages/remeda/src/internal/types/IfBoundedRecord.test-d.ts
deleted file mode 100644
index 92629c1..0000000
--- a/packages/remeda/src/internal/types/IfBoundedRecord.test-d.ts
+++ /dev/null
@@ -1,157 +0,0 @@
-import type { Tagged } from "type-fest";
-import { expectTypeOf, test } from "vitest";
-import type { IfBoundedRecord } from "./IfBoundedRecord";
-
-declare const SymbolFoo: unique symbol;
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-declare const SymbolBar: unique symbol;
-
-test("string", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<string, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Partial<Record<string, unknown>>>
-  >().toEqualTypeOf<false>();
-});
-
-test("number", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<number, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Partial<Record<number, unknown>>>
-  >().toEqualTypeOf<false>();
-});
-
-test("symbol", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<symbol, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Partial<Record<symbol, unknown>>>
-  >().toEqualTypeOf<false>();
-});
-
-test("union of string, number, symbol", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<number | string, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<string | symbol, unknown>>
-  >().toEqualTypeOf<false>();
-});
-
-test("string literals and their union", () => {
-  expectTypeOf<IfBoundedRecord<Record<"a", unknown>>>().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<"a" | "b", unknown>>
-  >().toEqualTypeOf<true>();
-});
-
-test("number literals and their union", () => {
-  expectTypeOf<IfBoundedRecord<Record<1, unknown>>>().toEqualTypeOf<true>();
-
-  expectTypeOf<IfBoundedRecord<Record<1 | 2, unknown>>>().toEqualTypeOf<true>();
-});
-
-test("symbol literals and their union", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<typeof SymbolFoo, unknown>>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<typeof SymbolBar | typeof SymbolFoo, unknown>>
-  >().toEqualTypeOf<true>();
-});
-
-test("unions between string, number, symbol", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<"a" | 1, unknown>>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<typeof SymbolFoo | "a", unknown>>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<typeof SymbolFoo | 1, unknown>>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<typeof SymbolFoo | "a" | 1, unknown>>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<{ 1: number } | { a: string; [SymbolFoo]: number }>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<{ 1?: number } | { a?: string; [SymbolFoo]: number }>
-  >().toEqualTypeOf<true>();
-});
-
-test("unions with unbounded types", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<number | "a", unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<string | 1, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<1, unknown> | Record<string, unknown>>
-  >().toEqualTypeOf<false>();
-});
-
-test("branded types", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<Tagged<string, symbol>, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<Tagged<number, symbol>, unknown>>
-  >().toEqualTypeOf<false>();
-});
-
-test("bounded template strings", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<`a_${1 | 2}`, unknown>>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<`${"a" | "b"}_${1 | 2}`, unknown>>
-  >().toEqualTypeOf<true>();
-
-  expectTypeOf<
-    IfBoundedRecord<
-      Record<`${1 | 2}_${1 | 2}_${1 | 2}_${1 | 2}_${1 | 2}`, unknown>
-    >
-  >().toEqualTypeOf<true>();
-});
-
-test("unbounded template strings", () => {
-  expectTypeOf<
-    IfBoundedRecord<Record<`a_${number}`, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<`${"a" | "b"}_${number}`, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<Record<`a_${string}`, unknown>>
-  >().toEqualTypeOf<false>();
-
-  expectTypeOf<
-    IfBoundedRecord<
-      Record<`${string}_${number}_${string}_${number}_${string}`, unknown>
-    >
-  >().toEqualTypeOf<false>();
-});
diff --git a/packages/remeda/src/internal/types/IsBounded.test-d.ts b/packages/remeda/src/internal/types/IsBounded.test-d.ts
new file mode 100644
index 0000000..74f0f4f
--- /dev/null
+++ b/packages/remeda/src/internal/types/IsBounded.test-d.ts
@@ -0,0 +1,85 @@
+import type { Tagged } from "type-fest";
+import { expectTypeOf, test } from "vitest";
+import type { IsBounded } from "./IsBounded";
+
+declare const SymbolFoo: unique symbol;
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+declare const SymbolBar: unique symbol;
+
+declare function isBounded<T>(data: T): IsBounded<T>;
+
+test("string", () => {
+  expectTypeOf(isBounded("")).toEqualTypeOf<false>();
+});
+
+test("number", () => {
+  expectTypeOf(isBounded(1)).toEqualTypeOf<false>();
+});
+
+test("symbol", () => {
+  expectTypeOf(isBounded(SymbolFoo as symbol)).toEqualTypeOf<false>();
+});
+
+test("union of string, number, symbol", () => {
+  expectTypeOf(isBounded("" as string | number)).toEqualTypeOf<false>();
+  expectTypeOf(isBounded("" as string | symbol)).toEqualTypeOf<false>();
+});
+
+test("string literals and their union", () => {
+  expectTypeOf(isBounded("a" as const)).toEqualTypeOf<true>();
+  expectTypeOf(isBounded("a" as "a" | "b")).toEqualTypeOf<true>();
+});
+
+test("number literals and their union", () => {
+  expectTypeOf(isBounded(1 as const)).toEqualTypeOf<true>();
+  expectTypeOf(isBounded(1 as 1 | 2)).toEqualTypeOf<true>();
+});
+
+test("symbol literals and their union", () => {
+  expectTypeOf(isBounded(SymbolFoo)).toEqualTypeOf<true>();
+  expectTypeOf(
+    isBounded(SymbolFoo as typeof SymbolFoo | typeof SymbolBar),
+  ).toEqualTypeOf<true>();
+});
+
+test("unions between string, number, symbol", () => {
+  expectTypeOf(isBounded("a" as "a" | 1)).toEqualTypeOf<true>();
+  expectTypeOf(isBounded("a" as "a" | typeof SymbolFoo)).toEqualTypeOf<true>();
+  expectTypeOf(isBounded(1 as 1 | typeof SymbolFoo)).toEqualTypeOf<true>();
+  expectTypeOf(
+    isBounded("a" as "a" | 1 | typeof SymbolFoo),
+  ).toEqualTypeOf<true>();
+});
+
+test("unions with unbounded types", () => {
+  expectTypeOf(isBounded("a" as "a" | number)).toEqualTypeOf<false>();
+  expectTypeOf(isBounded(1 as 1 | string)).toEqualTypeOf<false>();
+});
+
+test("branded types", () => {
+  expectTypeOf(isBounded("" as Tagged<string, symbol>)).toEqualTypeOf<false>();
+  expectTypeOf(isBounded(1 as Tagged<number, symbol>)).toEqualTypeOf<false>();
+});
+
+test("bounded template strings", () => {
+  expectTypeOf(isBounded("a_1" as `a_${1 | 2}`)).toEqualTypeOf<true>();
+  expectTypeOf(
+    isBounded("a_1" as `${"a" | "b"}_${1 | 2}`),
+  ).toEqualTypeOf<true>();
+  expectTypeOf(
+    isBounded("1_1_1_1_1" as `${1 | 2}_${1 | 2}_${1 | 2}_${1 | 2}_${1 | 2}`),
+  ).toEqualTypeOf<true>();
+});
+
+test("unbounded template strings", () => {
+  expectTypeOf(isBounded("a_1" as `a_${number}`)).toEqualTypeOf<false>();
+  expectTypeOf(
+    isBounded("a_1" as `${"a" | "b"}_${number}`),
+  ).toEqualTypeOf<false>();
+  expectTypeOf(isBounded("a_hello" as `a_${string}`)).toEqualTypeOf<false>();
+  expectTypeOf(
+    isBounded(
+      "a_1_b_2_c" as `${string}_${number}_${string}_${number}_${string}`,
+    ),
+  ).toEqualTypeOf<false>();
+});
diff --git a/packages/remeda/src/pick.test-d.ts b/packages/remeda/src/pick.test-d.ts
index e6fb2cc..a26095e 100644
--- a/packages/remeda/src/pick.test-d.ts
+++ b/packages/remeda/src/pick.test-d.ts
@@ -1,84 +1,1146 @@
+import type { EmptyObject } from "type-fest";
 import { describe, expectTypeOf, test } from "vitest";
 import { keys } from "./keys";
 import { pick } from "./pick";
-import { pipe } from "./pipe";
 
-describe("data first", () => {
-  test("non existing prop", () => {
+describe("bounded object types", () => {
+  const DATA = { a: "required", c: undefined } as {
+    a: "required";
+    b?: "optional";
+    c: "undefinable" | undefined;
+    d?: "optional-undefinable" | undefined;
+  };
+
+  test("enforces keys must exist on object", () => {
     // @ts-expect-error [ts2322] -- should not allow non existing props
-    pick({ a: 1, b: 2, c: 3, d: 4 }, ["not", "in"]);
+    pick(DATA, ["not", "in"]);
   });
 
-  test("complex type", () => {
-    const obj = { a: 1 } as { a: number } | { a?: number; b: string };
-    const result = pick(obj, ["a"]);
+  test("doesn't widen key types", () => {
+    // @ts-expect-error [ts2345] -- string is too wide for object
+    pick(DATA, ["a"] as [string]);
+  });
 
-    expectTypeOf(result).toEqualTypeOf<
-      Pick<{ a: number } | { a?: number; b: string }, "a">
-    >();
+  test("empty keys tuple", () => {
+    expectTypeOf(pick(DATA, [])).toEqualTypeOf<EmptyObject>();
   });
 
-  test("infers the key types from the keys array (issue #886)", () => {
-    const data = { foo: "hello", bar: "world" };
+  describe("fixed tuple of literal keys", () => {
+    test("required key only", () => {
+      expectTypeOf(pick(DATA, ["a"])).toEqualTypeOf<{
+        a: "required";
+      }>();
+    });
+
+    test("optional key only", () => {
+      expectTypeOf(pick(DATA, ["b"])).toEqualTypeOf<{
+        b?: "optional";
+      }>();
+    });
+
+    test("undefinable key only", () => {
+      expectTypeOf(pick(DATA, ["c"])).toEqualTypeOf<{
+        c: "undefinable" | undefined;
+      }>();
+    });
+
+    test("optional-undefinable key only", () => {
+      expectTypeOf(pick(DATA, ["d"])).toEqualTypeOf<{
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("required and optional keys", () => {
+      expectTypeOf(pick(DATA, ["a", "b"])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("required and undefinable keys", () => {
+      expectTypeOf(pick(DATA, ["a", "c"])).toEqualTypeOf<{
+        a: "required";
+        c: "undefinable" | undefined;
+      }>();
+    });
+
+    test("required and optional-undefinable keys", () => {
+      expectTypeOf(pick(DATA, ["a", "d"])).toEqualTypeOf<{
+        a: "required";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
 
-    const raw = pick(data, ["foo"]);
+    test("optional and undefinable keys", () => {
+      expectTypeOf(pick(DATA, ["b", "c"])).toEqualTypeOf<{
+        b?: "optional";
+        c: "undefinable" | undefined;
+      }>();
+    });
 
-    expectTypeOf(raw).toEqualTypeOf<{ foo: string }>();
+    test("optional and optional-undefinable keys", () => {
+      expectTypeOf(pick(DATA, ["b", "d"])).toEqualTypeOf<{
+        b?: "optional";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
 
-    const wrapped = keys(pick(data, ["foo"]));
+    test("undefinable and optional-undefinable keys", () => {
+      expectTypeOf(pick(DATA, ["c", "d"])).toEqualTypeOf<{
+        c: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
 
-    expectTypeOf(wrapped).toEqualTypeOf<Array<"foo">>();
+    test("all except optional-undefinable", () => {
+      expectTypeOf(pick(DATA, ["a", "b", "c"])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+        c: "undefinable" | undefined;
+      }>();
+    });
 
-    const withConstKeys = keys(pick(data, ["foo"] as const));
+    test("all except undefinable", () => {
+      expectTypeOf(pick(DATA, ["a", "b", "d"])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
 
-    expectTypeOf(withConstKeys).toEqualTypeOf<Array<"foo">>();
+    test("all except optional", () => {
+      expectTypeOf(pick(DATA, ["a", "c", "d"])).toEqualTypeOf<{
+        a: "required";
+        c: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("all except required", () => {
+      expectTypeOf(pick(DATA, ["b", "c", "d"])).toEqualTypeOf<{
+        b?: "optional";
+        c: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("all keys", () => {
+      expectTypeOf(pick(DATA, ["a", "b", "c", "d"])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+        c: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
   });
 
-  test("handles optional keys (issue #911)", () => {
-    const data = { foo: "hello", bar: "world" } as const;
-    const result = pick(data, [] as Array<keyof typeof data>);
+  describe("single union key", () => {
+    test("required or optional", () => {
+      expectTypeOf(pick(DATA, ["a" as "a" | "b"])).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+    });
 
-    expectTypeOf(result).toEqualTypeOf<{
-      readonly foo?: "hello";
-      readonly bar?: "world";
-    }>();
+    test("required or undefinable", () => {
+      expectTypeOf(pick(DATA, ["a" as "a" | "c"])).toEqualTypeOf<{
+        a?: "required";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("required or optional-undefinable", () => {
+      expectTypeOf(pick(DATA, ["a" as "a" | "d"])).toEqualTypeOf<{
+        a?: "required";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("optional or undefinable", () => {
+      expectTypeOf(pick(DATA, ["b" as "b" | "c"])).toEqualTypeOf<{
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("optional or optional-undefinable", () => {
+      expectTypeOf(pick(DATA, ["b" as "b" | "d"])).toEqualTypeOf<{
+        b?: "optional";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("undefinable or optional-undefinable", () => {
+      expectTypeOf(pick(DATA, ["c" as "c" | "d"])).toEqualTypeOf<{
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("required, optional, and undefinable", () => {
+      expectTypeOf(pick(DATA, ["a" as "a" | "b" | "c"])).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("required, optional, and optional-undefinable", () => {
+      expectTypeOf(pick(DATA, ["a" as "a" | "b" | "d"])).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("required, undefinable, and optional-undefinable", () => {
+      expectTypeOf(pick(DATA, ["a" as "a" | "c" | "d"])).toEqualTypeOf<{
+        a?: "required";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("optional, undefinable, and optional-undefinable", () => {
+      expectTypeOf(pick(DATA, ["b" as "b" | "c" | "d"])).toEqualTypeOf<{
+        b?: "optional";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("all key types", () => {
+      expectTypeOf(pick(DATA, ["a" as "a" | "b" | "c" | "d"])).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+  });
+
+  describe("multiple union keys", () => {
+    test("with partial overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a" as "a" | "b", "b" as "b" | "c"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("with full overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a" as "a" | "b", "b" as "a" | "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("without overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a" as "a" | "b", "c" as "c" | "d"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+  });
+
+  describe("mixed literal and union keys", () => {
+    test("with partial overlap", () => {
+      expectTypeOf(pick(DATA, ["a", "b" as "a" | "b"])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("without overlap", () => {
+      expectTypeOf(pick(DATA, ["a", "b" as "b" | "c"])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+  });
+
+  describe("array with literal key", () => {
+    test("required key", () => {
+      expectTypeOf(pick(DATA, [] as Array<"a">)).toEqualTypeOf<{
+        a?: "required";
+      }>();
+    });
+
+    test("optional key", () => {
+      expectTypeOf(pick(DATA, [] as Array<"b">)).toEqualTypeOf<{
+        b?: "optional";
+      }>();
+    });
+
+    test("undefinable key", () => {
+      expectTypeOf(pick(DATA, [] as Array<"c">)).toEqualTypeOf<{
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("optional-undefinable key", () => {
+      expectTypeOf(pick(DATA, [] as Array<"d">)).toEqualTypeOf<{
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+  });
+
+  describe("array with union keys", () => {
+    test("required or optional", () => {
+      expectTypeOf(pick(DATA, [] as Array<"a" | "b">)).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("required or undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"a" | "c">)).toEqualTypeOf<{
+        a?: "required";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("required or optional-undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"a" | "d">)).toEqualTypeOf<{
+        a?: "required";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("optional or undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"b" | "c">)).toEqualTypeOf<{
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("optional or optional-undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"b" | "d">)).toEqualTypeOf<{
+        b?: "optional";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("undefinable or optional-undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"c" | "d">)).toEqualTypeOf<{
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("required, optional or undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"a" | "b" | "c">)).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("required, optional or optional-undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"a" | "b" | "d">)).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("required, undefinable or optional-undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"a" | "c" | "d">)).toEqualTypeOf<{
+        a?: "required";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("optional, undefinable or optional-undefinable picked", () => {
+      expectTypeOf(pick(DATA, [] as Array<"b" | "c" | "d">)).toEqualTypeOf<{
+        b?: "optional";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+
+    test("all keys", () => {
+      expectTypeOf(
+        pick(DATA, [] as Array<"a" | "b" | "c" | "d">),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+  });
+
+  describe("non-empty (prefix) arrays", () => {
+    test("all literals, with overlap", () => {
+      expectTypeOf(pick(DATA, ["a"] as ["a", ...Array<"a">])).toEqualTypeOf<{
+        a: "required";
+      }>();
+    });
+
+    test("all literals, no overlap", () => {
+      expectTypeOf(pick(DATA, ["a"] as ["a", ...Array<"b">])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(pick(DATA, ["b"] as ["b", ...Array<"a">])).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("with unions, partial overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a", ...Array<"a" | "b">]),
+      ).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["b"] as ["b", ...Array<"a" | "b">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a" | "b", ...Array<"a">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a" | "b", ...Array<"b">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a" | "b", ...Array<"b" | "c">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("with unions, full overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a" | "b", ...Array<"a" | "b">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("with unions, no overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a", ...Array<"b" | "c">]),
+      ).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["b"] as ["b", ...Array<"a" | "c">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a" | "b", ...Array<"c">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["b"] as ["b" | "c", ...Array<"a">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as ["a" | "b", ...Array<"c" | "d">]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
+  });
+
+  describe("non-empty (suffix) arrays", () => {
+    test("all literals, with overlap", () => {
+      expectTypeOf(pick(DATA, ["a"] as [...Array<"a">, "a"])).toEqualTypeOf<{
+        a: "required";
+      }>();
+    });
+
+    test("all literals, no overlap", () => {
+      expectTypeOf(pick(DATA, ["a"] as [...Array<"b">, "a"])).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(pick(DATA, ["b"] as [...Array<"a">, "b"])).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("with unions, partial overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"a" | "b">, "a"]),
+      ).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["b"] as [...Array<"a" | "b">, "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"a">, "a" | "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"b">, "a" | "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"b" | "c">, "a" | "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("with unions, full overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"a" | "b">, "a" | "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+      }>();
+    });
+
+    test("with unions, no overlap", () => {
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"b" | "c">, "a"]),
+      ).toEqualTypeOf<{
+        a: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["b"] as [...Array<"a" | "c">, "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"c">, "a" | "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["b"] as [...Array<"a">, "b" | "c"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(
+        pick(DATA, ["a"] as [...Array<"c" | "d">, "a" | "b"]),
+      ).toEqualTypeOf<{
+        a?: "required";
+        b?: "optional";
+        c?: "undefinable" | undefined;
+        d?: "optional-undefinable" | undefined;
+      }>();
+    });
   });
 });
 
-describe("data last", () => {
-  test("non existing prop", () => {
-    pipe(
-      { a: 1, b: 2, c: 3, d: 4 },
-      // @ts-expect-error [ts2345] -- should not allow non existing props
-      pick(["not", "in"]),
-    );
+// @see https://github.com/remeda/remeda/issues/1128
+describe("unbounded record types (Issue #1128)", () => {
+  const DATA = {} as Record<string, "required">;
+  const UNDEFINABLE = {} as Record<string, "undefinable" | undefined>;
+
+  test("enforces keys must exist on object", () => {
+    // @ts-expect-error [ts2322] -- should not allow non existing props
+    pick(DATA, [1, 2]);
+  });
+
+  test("doesn't widen key types", () => {
+    // @ts-expect-error [ts2345] -- string is too wide for object
+    pick(DATA, ["a"] as [PropertyKey]);
+  });
+
+  test("empty keys tuple", () => {
+    expectTypeOf(pick(DATA, [])).toEqualTypeOf<EmptyObject>();
   });
 
-  test("complex type", () => {
-    const obj = { a: 1 } as { a: number } | { a?: number; b: string };
-    const result = pipe(obj, pick(["a"]));
+  describe("fixed tuple keys", () => {
+    test("literal keys", () => {
+      const picks = ["a", "b"] as const;
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("non-overlapping union keys", () => {
+      const picks = ["a", "c"] as ["a" | "b", "c" | "d"];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+        c?: "required";
+        d?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+        c?: "undefinable" | undefined;
+        d?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("partially overlapping union keys", () => {
+      const picks = ["a", "b"] as ["a" | "b", "b" | "c"];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+        c?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("fully overlapping union keys", () => {
+      const picks = ["a", "b"] as ["a" | "b", "a" | "b"];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("literal and overlapping union keys", () => {
+      const picks = ["a", "b"] as ["a", "a" | "b"];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("literal and non-overlapping union keys", () => {
+      const picks = ["a", "b"] as ["a", "b" | "c"];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+        c?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("primitive keys", () => {
+      const picks = ["a", "b"] as [string, string];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+        Record<string, "required">
+      >();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+    });
 
-    expectTypeOf(result).toEqualTypeOf<
-      Pick<{ a: number } | { a?: number; b: string }, "a">
+    test("primitive and singular literal keys", () => {
+      const picks = ["a", "b"] as ["a", string];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+        Record<string, "required">
+      >();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+    });
+
+    test("primitive and union of literal", () => {
+      const picks = ["a", "b"] as ["a" | "b", string];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+        Record<string, "required">
+      >();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+    });
+  });
+
+  describe("array keys", () => {
+    test("literal key", () => {
+      const picks = [] as Array<"a">;
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("union keys", () => {
+      const picks = [] as Array<"a" | "b">;
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("primitive keys", () => {
+      const picks = [] as Array<string>;
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+        Record<string, "required">
+      >();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+    });
+  });
+
+  describe("prefix array keys", () => {
+    test("non-overlapping literal keys", () => {
+      const picks = ["a"] as ["a", ...Array<"b">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("overlapping literal keys", () => {
+      const picks = ["a"] as ["a", ...Array<"a">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("union of non-overlapping literals", () => {
+      const picks = ["a"] as ["a" | "b", ...Array<"c" | "d">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+        c?: "required";
+        d?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+        c?: "undefinable" | undefined;
+        d?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("union of partially overlapping literals", () => {
+      const picks = ["a"] as ["a" | "b", ...Array<"b" | "c">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+        c?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("union of fully overlapping literals", () => {
+      const picks = ["a"] as ["a" | "b", ...Array<"a" | "b">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("literals and overlapping union of literals", () => {
+      const picks = ["a"] as ["a", ...Array<"a" | "b">];
+      const alt = ["a"] as ["a" | "b", ...Array<"b">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(pick(DATA, alt)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, alt)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("literals and non-overlapping union of literals", () => {
+      const picks = ["a"] as ["a", ...Array<"b" | "c">];
+      const alt = ["a"] as ["a" | "b", ...Array<"c">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+        c?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+        c?: "undefinable" | undefined;
+      }>();
+      expectTypeOf(pick(DATA, alt)).toEqualTypeOf<{
+        a?: "required";
+        b?: "required";
+        c?: "required";
+      }>();
+      expectTypeOf(pick(UNDEFINABLE, alt)).toEqualTypeOf<{
+        a?: "undefinable" | undefined;
+        b?: "undefinable" | undefined;
+        c?: "undefinable" | undefined;
+      }>();
+    });
+
+    test("primitive keys", () => {
+      const picks = ["a"] as [string, ...Array<string>];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+        Record<string, "required">
+      >();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+    });
+
+    test("primitive and singular literal keys", () => {
+      const picks = ["a"] as ["a", ...Array<string>];
+      const alt = ["a"] as [string, ...Array<"a">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+        Record<string, "required">
+      >();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+      expectTypeOf(pick(DATA, alt)).toEqualTypeOf<Record<string, "required">>();
+      expectTypeOf(pick(UNDEFINABLE, alt)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+    });
+
+    test("primitive and union of literal", () => {
+      const picks = ["a"] as ["a" | "b", ...Array<string>];
+      const alt = ["a"] as [string, ...Array<"a" | "b">];
+
+      expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+        Record<string, "required">
+      >();
+      expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+      expectTypeOf(pick(DATA, alt)).toEqualTypeOf<Record<string, "required">>();
+      expectTypeOf(pick(UNDEFINABLE, alt)).toEqualTypeOf<
+        Record<string, "undefinable" | undefined>
+      >();
+    });
+  });
+
+  test("narrows on unbounded keys but doesn't make it partial", () => {
+    const picks = [] as Array<`prefix_${string}`>;
+
+    expectTypeOf(pick(DATA, picks)).toEqualTypeOf<
+      Record<`prefix_${string}`, "required">
+    >();
+    expectTypeOf(pick(UNDEFINABLE, picks)).toEqualTypeOf<
+      Record<`prefix_${string}`, "undefinable" | undefined>
     >();
   });
 });
 
-test("multiple keys", () => {
-  type Data = { aProp: string; bProp: string };
+describe("union object types", () => {
+  describe("keys exist in all union members", () => {
+    test("same type", () => {
+      expectTypeOf(
+        pick(
+          { a: "a", b: "b", c: "c" } as
+            | { a: "a"; b: "b"; c: "c" }
+            | { a: "a"; b: "b"; d: "d" },
+          ["a", "b"],
+        ),
+      ).toEqualTypeOf<{ a: "a"; b: "b" }>();
+    });
 
-  const obj: Data = {
-    aProp: "p1",
+    test("different optionality", () => {
+      expectTypeOf(
+        pick(
+          { a: "a", b: "b", c: "c" } as
+            | { a: "a"; b: "b"; c: "c" }
+            | { a?: "a"; b: "b"; d: "d" },
+          ["a", "b"],
+        ),
+      ).toEqualTypeOf<{ a: "a"; b: "b" } | { a?: "a"; b: "b" }>();
+    });
 
-    bProp: "p2",
-  };
+    test("different types", () => {
+      expectTypeOf(
+        pick(
+          { a: "a", b: "b", c: "c" } as
+            | { a: "a"; b: "b"; c: "c" }
+            | { a: "alt_a"; b: "alt_b"; d: "d" },
+          ["a", "b"],
+        ),
+      ).toEqualTypeOf<{ a: "a"; b: "b" } | { a: "alt_a"; b: "alt_b" }>();
+    });
+  });
+
+  describe("keys exist in some union members", () => {
+    test("same type", () => {
+      const DATA = { a: "a", b: "b", c: "c" } as
+        | { a: "a"; b: "b"; c: "c" }
+        | { a: "a"; b: "b"; d: "d" };
 
-  const result = pipe(obj, pick(["aProp", "bProp"]));
+      expectTypeOf(pick(DATA, ["a", "c"])).toEqualTypeOf<
+        { a: "a"; c: "c" } | { a: "a" }
+      >();
+      expectTypeOf(pick(DATA, ["a", "d"])).toEqualTypeOf<
+        { a: "a" } | { a: "a"; d: "d" }
+      >();
+    });
 
-  expectTypeOf(result).toEqualTypeOf<Pick<Data, "aProp" | "bProp">>();
+    test("different optionality", () => {
+      const DATA = { a: "a", b: "b", c: "c" } as
+        | { a: "a"; b: "b"; c: "c" }
+        | { a?: "a"; b: "b"; d: "d" };
+
+      expectTypeOf(pick(DATA, ["a", "c"])).toEqualTypeOf<
+        { a: "a"; c: "c" } | { a?: "a" }
+      >();
+      expectTypeOf(pick(DATA, ["a", "d"])).toEqualTypeOf<
+        { a: "a" } | { a?: "a"; d: "d" }
+      >();
+    });
+
+    test("different types", () => {
+      const DATA = { a: "a", b: "b", c: "c" } as
+        | { a: "a"; b: "b"; c: "c" }
+        | { a: "alt_a"; b: "alt_b"; d: "alt_d" };
+
+      expectTypeOf(pick(DATA, ["a", "c"])).toEqualTypeOf<
+        { a: "a"; c: "c" } | { a: "alt_a" }
+      >();
+      expectTypeOf(pick(DATA, ["a", "d"])).toEqualTypeOf<
+        { a: "a" } | { a: "alt_a"; d: "alt_d" }
+      >();
+    });
+  });
+
+  test("keys belong to single union member", () => {
+    expectTypeOf(
+      pick(
+        { a: "a", b: "b", c: "c" } as
+          | { a: "a"; b: "b"; c: "c" }
+          | { d: "d"; e: "e"; f: "f" },
+        ["a", "b"],
+      ),
+    ).toEqualTypeOf<{ a: "a"; b: "b" } | EmptyObject>();
+  });
+
+  test("keys distributed across union members", () => {
+    expectTypeOf(
+      pick({ a: "a", b: "b" } as { a: "a"; b: "b" } | { c: "c"; d: "d" }, [
+        "a",
+        "d",
+      ]),
+    ).toEqualTypeOf<{ a: "a" } | { d: "d" }>();
+  });
+});
+
+describe("union key array types", () => {
+  describe("disjoint literal keys", () => {
+    test("bounded plain object", () => {
+      expectTypeOf(
+        pick({ a: "a", b: "b" }, ["a"] as ["a"] | ["b"]),
+      ).toEqualTypeOf<{ a: string } | { b: string }>();
+    });
+
+    test("unbounded record", () => {
+      expectTypeOf(
+        pick({} as Record<string, "value">, ["a"] as ["a"] | ["b"]),
+      ).toEqualTypeOf<{ a?: "value" } | { b?: "value" }>();
+    });
+  });
+
+  describe("overlapping literal keys", () => {
+    const picks = ["a", "b"] as ["a", "b"] | ["b", "c"];
+
+    test("bounded plain object", () => {
+      expectTypeOf(pick({ a: "a", b: "b", c: "c" }, picks)).toEqualTypeOf<
+        { a: string; b: string } | { b: string; c: string }
+      >();
+    });
+
+    test("unbounded record", () => {
+      expectTypeOf(pick({} as Record<string, "value">, picks)).toEqualTypeOf<
+        { a?: "value"; b?: "value" } | { b?: "value"; c?: "value" }
+      >();
+    });
+  });
+
+  describe("overlapping union keys", () => {
+    const picks = ["a", "b"] as ["a" | "b", "b" | "c"] | ["b" | "c", "c" | "d"];
+
+    test("bounded plain object", () => {
+      expectTypeOf(
+        pick({ a: "a", b: "b", c: "c", d: "d" }, picks),
+      ).toEqualTypeOf<
+        | { a?: string; b?: string; c?: string }
+        | { b?: string; c?: string; d?: string }
+      >();
+    });
+
+    test("unbounded record", () => {
+      expectTypeOf(pick({} as Record<string, "value">, picks)).toEqualTypeOf<
+        | { a?: "value"; b?: "value"; c?: "value" }
+        | { b?: "value"; c?: "value"; d?: "value" }
+      >();
+    });
+  });
+
+  describe("different array shapes", () => {
+    const picks = ["a", "b"] as ["a" | "b", "b" | "c"] | Array<"d">;
+
+    test("bounded plain object", () => {
+      expectTypeOf(
+        pick({ a: "a", b: "b", c: "c", d: "d" }, picks),
+      ).toEqualTypeOf<
+        { a?: string; b?: string; c?: string } | { d?: string }
+      >();
+    });
+
+    test("unbounded record", () => {
+      expectTypeOf(pick({} as Record<string, "value">, picks)).toEqualTypeOf<
+        { a?: "value"; b?: "value"; c?: "value" } | { d?: "value" }
+      >();
+    });
+  });
+
+  test("mix of literals and primitives", () => {
+    expectTypeOf(
+      pick({} as Record<string, "value">, [] as Array<string> | Array<"a">),
+    ).toEqualTypeOf<Record<string, "value"> | { a?: "value" }>();
+  });
+});
+
+test("result is mutable", () => {
+  expectTypeOf(pick({ a: 1 } as const, ["a"])).toEqualTypeOf<{
+    a: 1;
+  }>();
+
+  expectTypeOf(
+    pick({} as Readonly<Record<string, "something">>, [] as Array<string>),
+  ).toEqualTypeOf<Record<string, "something">>();
+});
+
+// @see https://github.com/remeda/remeda/issues/886
+describe("key type inference (issue #886)", () => {
+  test("base", () => {
+    expectTypeOf(pick({ foo: "hello", bar: "world" }, ["foo"])).toEqualTypeOf<{
+      foo: string;
+    }>();
+  });
+
+  test("wrapped", () => {
+    expectTypeOf(
+      keys(pick({ foo: "hello", bar: "world" }, ["foo"])),
+    ).toEqualTypeOf<Array<"foo">>();
+  });
+
+  test("with const key", () => {
+    expectTypeOf(
+      keys(pick({ foo: "hello", bar: "world" }, ["foo"] as const)),
+    ).toEqualTypeOf<Array<"foo">>();
+  });
 });
 
-test("support inherited properties", () => {
+test("supports inherited properties", () => {
   class BaseClass {
     // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- This is fine...
     public testProp(): string {
@@ -86,9 +1148,8 @@ test("support inherited properties", () => {
     }
   }
   class TestClass extends BaseClass {}
-  const testClass = new TestClass();
 
-  expectTypeOf(pick(testClass, ["testProp"])).toEqualTypeOf<{
+  expectTypeOf(pick(new TestClass(), ["testProp"])).toEqualTypeOf<{
     testProp: () => string;
   }>();
 });