A GitHub Copilot Chat participant (@formatter) that reformats TypeScript code: it collapses function signatures and calls onto a single line while keeping function bodies multi-line, adds missing semicolons, and strips blank lines — without touching comments, strings, or template literals.
Features
Collapses function signatures to a single line, keeping the body multi-line
Collapses function calls to a single line
Adds missing semicolons to statement ends
Removes blank/empty lines
Preserves comments, template literals, and string contents untouched
Before:
function add(
a: number,
b: number
): number {
return a + b;
}
After:
function add(a: number, b: number): number {
return a + b;
}
Usage
Select the TypeScript code you want to format in the editor
Open GitHub Copilot Chat (Ctrl+Alt+I)
Type @formatter format this
The formatted code is applied to your selection automatically (press Ctrl+Z to undo)
You can also invoke @formatter without a selection to have it format a code snippet pasted directly into the chat.
Requirements
GitHub Copilot installed and signed in, with an active Copilot subscription (the agent sends your code to a Copilot language model to perform the formatting)
VS Code 1.108.1 or higher
Known limitations
Formatting quality depends on the underlying Copilot language model and is not guaranteed to be 100% deterministic
Only TypeScript formatting rules are targeted; other languages are not supported