Skip to main content
Glama
debug.md1.47 kB
# 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 output - `rename = "label"` - Use a custom label instead of the field name ## Example ```typescript before /** @derive(Debug) */ class User { /** @debug({ rename: "id" }) */ userId: number; /** @debug({ skip: true }) */ password: string; email: string; } ``` ```typescript after 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(', ') + ' }'; } ```

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/macroforge-ts/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server