Skip to content

Releases: phamquyetthang/ts-nester

v1.0.5

09 Jul 07:59

Choose a tag to compare

Update DeepFlattenedTypePaths

v1.0.4

09 Jul 06:50

Choose a tag to compare

Update github action

v1.0.3

05 Jul 08:49

Choose a tag to compare

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

05 Jul 09:00
02d1e59

Choose a tag to compare

Update package.json

v1.0.2

15 Jun 03:10

Choose a tag to compare

Add ChildItemType, ChildType

v1.0.1

14 Jun 07:54

Choose a tag to compare

update version

v1.0.0

14 Jun 07:49
0b9cf44

Choose a tag to compare

Update npm-publish.yml