API Stability Notice
Macroforge is under active development. The API is not yet stable and may change between versions. Some documentation sections may be outdated.
Debug
The Debug macro generates a human-readable toString() method for
TypeScript classes, interfaces, enums, and type aliases.
Generated Output
Classes: Generates a standalone function classNameToString(value) and a static wrapper
method static toString(value) returning a string like "ClassName { field1: value1, field2: value2 }".
Enums: Generates a standalone function enumNameToString(value) that performs
reverse lookup on numeric enums.
Interfaces: Generates a standalone function interfaceNameToString(value).
Type Aliases: Generates a standalone function using JSON.stringify for complex types, or field enumeration for object types.
Field-Level Options
The @debug decorator supports:
skip- Exclude the field from debug outputrename = "label"- Use a custom label instead of the field name
Example
/** @derive(Debug) */
class User {
/** @debug({ rename: "id" }) */
userId: number;
/** @debug({ skip: true }) */
password: string;
email: string;
}class User {
userId: number;
password: string;
email: string;
static toString(value: User): string {
return userToString(value);
}
}
export function userToString(value: User): string {
const parts: string[] = [];
parts.push('id: ' + value.userId);
parts.push('email: ' + value.email);
return 'User { ' + parts.join(', ') + ' }';
}Generated output:
class User {
userId: number;
password: string;
email: string;
static toString(value: User): string {
return userToString(value);
}
}
export function userToString(value: User): string {
const parts: string[] = [];
parts.push('id: ' + value.userId);
parts.push('email: ' + value.email);
return 'User { ' + parts.join(', ') + ' }';
}