Feature Request
Type Expectation
The runtime implementation for deepStrictPick exists, but its inverse operation deepStrictOmit has no runtime implementation. Since Pick and Omit are commonly used as a pair, a deepStrictOmit runtime function is needed for API completeness.
Example Type
const input = {
a: 1,
b: { c: 2, d: 3 },
e: [{ f: 4, g: 5 }],
};
const result = deepStrictOmit(input, 'b.c');
// result: { a: 1, b: { d: 3 }, e: [{ f: 4, g: 5 }] }
// typeof result: DeepStrictOmit<typeof input, 'b.c'>
const result2 = deepStrictOmit(input, 'e[*].f');
// result2: { a: 1, b: { c: 2, d: 3 }, e: [{ g: 5 }] }
Proposed Solution
- Create
src/functions/DeepStrictOmit.ts
- Signature:
deepStrictOmit<T extends object, K extends DeepStrictObjectKeys<T>>(input: T, key: K): DeepStrictOmit<T, K>
- Reference the traverse pattern from
deepStrictPick, but invert the logic (only remove specified keys)
- Add re-export to
src/functions/index.ts
- Use
[*] pattern for removing keys from each element during array traversal
Use Case
- Remove sensitive fields from API responses (
password, secret, etc.)
- Strip unnecessary nested fields before sending to client
- Provide a symmetric API alongside
deepStrictPick
Test Requirements
All changes must include the following tests:
-
Backward Compatibility
- All existing tests must pass
-
Feature Verification
- Top-level key omit (
deepStrictOmit(obj, 'a'))
- Nested key omit (
deepStrictOmit(obj, 'a.b'))
- Array inner key omit (
deepStrictOmit(obj, 'items[*].id'))
- Non-existent keys produce a type error (compile time)
- Return type matches
DeepStrictOmit<T, K>
-
Complex Type Stability
- 3+ levels of nested omit
- 2D array inner omit (
items[*].sub[*].value)
- Omit from objects with Date properties (Date preserved)
- Omit from objects with branded types
- Omitting all keys results in an empty object
- Empty array input
- Immutability check (input is not mutated)
How to verify:
npm run build:test && npm run test
npm run prettier
Feature Request
Type Expectation
The runtime implementation for
deepStrictPickexists, but its inverse operationdeepStrictOmithas no runtime implementation. Since Pick and Omit are commonly used as a pair, adeepStrictOmitruntime function is needed for API completeness.Example Type
Proposed Solution
src/functions/DeepStrictOmit.tsdeepStrictOmit<T extends object, K extends DeepStrictObjectKeys<T>>(input: T, key: K): DeepStrictOmit<T, K>deepStrictPick, but invert the logic (only remove specified keys)src/functions/index.ts[*]pattern for removing keys from each element during array traversalUse Case
password,secret, etc.)deepStrictPickTest Requirements
All changes must include the following tests:
Backward Compatibility
Feature Verification
deepStrictOmit(obj, 'a'))deepStrictOmit(obj, 'a.b'))deepStrictOmit(obj, 'items[*].id'))DeepStrictOmit<T, K>Complex Type Stability
items[*].sub[*].value)How to verify: