Releases: phamquyetthang/ts-nester
v1.0.5
v1.0.4
Update github action
v1.0.3
FlattenedTypePaths<T>
Generates a flattened representation of an object's type structure, mapping each nested path to its corresponding value type. This utility type iterates over each key generated by DotNestedKeys<T>
and resolves the type of the value at each nested path. The resulting type is an object with keys in the format 'parent.child', each mapping to the type of the value at that path.
Type Parameters
T
- The input object type to be flattened.
Example
const example = { foo: { bar: 123, baz: 456 } };
type Result = FlattenedTypePaths<typeof example>;
// Expected type: {'foo.bar': number, 'foo.baz': number}
DeepFlattenedTypePaths<T, Depth>
Recursively generates a flattened representation of an object's type structure, mapping each nested path to its corresponding value type up to a specified depth. This utility type iterates over each key in the object, and for objects at each level, it recursively applies itself to flatten the structure. The depth parameter controls how deep the type should recurse into the object's structure, allowing for selective depth flattening.
Type Parameters
T
- The input object type to be flattened.Depth
- A numeric literal type that specifies the maximum depth to flatten the object. A depth of 1 means no recursion.
Example
const example = {
b: {
c: 1,
d: 2,
e: {
f: 1,
g: {
k: 10,
l: "22",
},
},
},
};
// Flatten up to depth 2
type ResultDepth2 = DeepFlattenedTypePaths<typeof example, 2>;
// Expected type: { 'b.c': number, 'b.d': number, 'b.e': { f: number, g: { k: number, l: string } } }
// Flatten up to depth 3
type ResultDepth3 = DeepFlattenedTypePaths<typeof example, 3>;
// Expected type: { 'b.c': number, 'b.d': number, 'b.e.f': number, 'b.e.g.k': number, 'b.e.g.l': string }
v1.0.2-a
Update package.json
v1.0.2
Add ChildItemType, ChildType
v1.0.1
update version
v1.0.0
Update npm-publish.yml