Deep Utility Types

Deep Utility Types

Utility types for operations on nested objects. Fully type-safe, nice autocompletion, and even works with arrays.

Creating this library really allowed me to get deep into working with TypeScript’s type system. I later used a lot of what I learned here to create the type-safe query API of Crockpot.

import { DeepOmit } from 'deep-utility-types';
type Example = {
foo1: string;
foo2: {
bar1: string;
bar2: {
baz1: string;
baz2: string;
};
};
};
type Omitted = DeepOmit<Example, 'foo2.bar1' | 'foo2.bar2.baz1'>;
const omitted: Omitted = {
foo1: 'foo1',
foo2: {
bar2: {
baz2: 'baz2',
},
},
};

More examples can be found in the README.