Flattens deeply nested object types into a dot-separated union of keys, treating all optional keys as required. Ideal for working with deeply structured TypeScript types.
npm install deep-flatten-type


Deep Flatten Type Utility is a lightweight TypeScript utility that flattens deeply nested object types into a dot-separated union of keys. All optional keys are treated as required, ensuring flexibility and consistency.
Install via npm or yarn:
``bash`
npm install deep-flatten-typeor
yarn add deep-flatten-type
- TypeScript-First: Define and manipulate deeply nested object types with ease.
- Dot-Separated Union: Automatically flattens keys into a dot-separated union.
- Supports Optional Keys: Treats all optional keys as required.
Here's an example of how to use DeepFlatten:
`typescript
import { DeepFlatten } from "deep-flatten-type";
type NestedObject = {
a: {
b: {
c: number;
};
d: string;
};
e: boolean;
};
const paths: DeepFlatten
`
, DeepFlatten generates a union of string paths representing all possible keys:-
"e"
- "a.d"
- "a.b.c"API
$3
-
T: The deeply nested object type to be flattened.Returns: A union of dot-separated string paths for all keys in
T`.Contributions are welcome! If you encounter any issues or have feature requests, feel free to open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.