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.
TypeScript Plugin
The TypeScript plugin provides IDE integration for Macroforge, including error reporting, completions, and type checking for generated code.
Installation
Bash
npm install -D @macroforge/typescript-pluginConfiguration
Add the plugin to your tsconfig.json:
tsconfig.json
{
"compilerOptions": {
"plugins": [
{
"name": "@macroforge/typescript-plugin"
}
]
}
}VS Code Setup
VS Code uses its own TypeScript version by default. To use the workspace version (which includes plugins):
- Open the Command Palette (
Cmd/Ctrl + Shift + P) - Search for "TypeScript: Select TypeScript Version"
- Choose "Use Workspace Version"
Tip
Add this setting to your
.vscode/settings.json to make it permanent:.vscode/settings.json
{
"typescript.tsdk": "node_modules/typescript/lib"
}Features
Error Reporting
Errors in macro-generated code are reported at the @derive decorator position:
TypeScript
/** @derive(Debug) */ // <- Errors appear here
class User {
name: string;
}Completions
The plugin provides completions for generated methods:
TypeScript
const user = new User("Alice");
user.to // Suggests: toString(), toJSON(), etc.Type Information
Hover over generated methods to see their types:
TypeScript
// Hover over 'clone' shows:
// (method) User.clone(): User
const copy = user.clone();Troubleshooting
Plugin Not Loading
- Ensure you're using the workspace TypeScript version
- Restart the TypeScript server (Command Palette → "TypeScript: Restart TS Server")
- Check that the plugin is listed in
tsconfig.json
Errors Not Showing
If errors from macros aren't appearing:
- Make sure the Vite plugin is also installed (for source file watching)
- Check that your file is saved (plugins process on save)