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 |
|---|---|---|
|
| Random string, length 10, mixed charset by default |
|
| Random integer between 1 and 1000 |
|
|
|
|
| Date between 2000-01-01 and 4000-01-01 |
Enum (numeric or string) |
| Random member of the enum; every member is reachable |
Array |
| Array of 3 elements, each generated independently |
Nested array |
| 3×3 matrix (length applies per level) |
Tuple |
| Array with each position forged from its own type |
Function property |
| Callable returning a forged |
Literal union |
| Random member of the union |
Union with |
|
|
Interface / type literal |
| Object with every declared property forged |
Class |
| Object from constructor params and property declarations |
Inheritance |
| Properties of the whole chain are merged |
Generics |
| Generic arguments substituted |
Intersection |
| Properties of both sides combined |
Circular reference |
| Nested up to |
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
Per-type details: Primitives, Objects, Arrays, Tuples, Dates, Enums, Literals, Unions, Functions, Circular references.