Forger Help

Supported Types

The matrix below shows what Forger.create<T>() produces for every type kind, with the concrete behavior verified against the library specs.

Matrix

Type kind

Example

Produced value

string

create<string>()

Random string, length 10, mixed charset by default

number

create<number>()

Random integer between 1 and 1000

boolean

create<boolean>()

true or false

Date

create<Date>()

Date between 2000-01-01 and 4000-01-01

Enum (numeric or string)

create<Status>(), create<Kind>()

Random member of the enum; every member is reachable

Array

create<string[]>(), create<Array<T>>()

Array of 3 elements, each generated independently

Nested array

create<number[][]>()

3×3 matrix (length applies per level)

Tuple

create<[string, number]>()

Array with each position forged from its own type

Function property

calc: (a: number) => string

Callable returning a forged string each time it is invoked

Literal union

create<'a' \| 'b' \| 42 \| true>()

Random member of the union

Union with null/undefined

create<null \| number>()

null and undefined members are dropped; a real member wins

Interface / type literal

create<Student>()

Object with every declared property forged

Class

create<Foo>()

Object from constructor params and property declarations

Inheritance

interface B extends A

Properties of the whole chain are merged

Generics

create<Box<number>>()

Generic arguments substituted

Intersection

A & { id?: number }

Properties of both sides combined

Circular reference

interface Node { child?: Node }

Nested up to circularDepth (default 1), then null

Reading the matrix

  • Primitives follow SpoofSettings — ranges, lengths, and charsets can be tuned per call.

  • Containers (arrays, tuples, objects) recurse: every nested type is forged by the same rules, so Student[] gets full students, not empty objects.

  • Optional properties (name?: string) are generated like any other property.

  • Unions are rolled at runtime — a new call may pick a different member. When a test depends on a specific member, pin it with createWith or narrow the type argument itself.

Not really "supported", but forged anyway

Structural built-ins like Map, Set, or Promise are treated as regular object types: Forger forges their members (which are mostly methods) as data properties. The result is structurally populated but not a functioning Map. For those types, pin a real instance with createWith — see Caveats.

Where to go next

08 September 2026