Objects: Interfaces and Classes
Interfaces, type literals, and classes are forged by walking their declared members. This topic explains exactly what gets included.
Interfaces
Every declared property is forged according to its type, including optional and readonly ones:
Classes
For classes, two sources of properties are used:
constructor parameters with modifiers (
constructor(public name: string));property declarations with a type annotation (
age: number).
What is not included:
Member | Behavior |
|---|---|
| Skipped — they belong to the class, not the instance |
Fields without a type annotation ( | Forged as |
Methods ( | Forged as a data property of the return type, not a callable — see Functions and Caveats |
Getters / setters | Not treated as data; do not rely on them |
If you need a callable member, declare it as a function-typed property (calc: (a: number) => string) or pin a real implementation with createWith.
Nested objects
Objects recurse: a property typed as another interface or class is forged the same way, to any depth. Circular (self-referencing) types stop at the configured depth — see Circular references.
Intersections
Intersection types combine the members of every side:
Built-in structural types
Map, Set, Promise, and similar built-ins are forged structurally: their members — mostly methods — become data properties. The result type-checks but does not behave like a real Map. For behavioral doubles, pin real instances:
See Caveats for the full discussion.