What is the difference between an interface and a type alias?
Both describe the shape of an object. Interfaces support declaration merging — multiple interface User { … } blocks in scope combine into one — and they always have a stable, named identity in error messages. Type aliases support unions (type X = A | B), intersections, mapped types, and conditional types that interfaces cannot express. Use interface for object/class contracts that may need extension by consumers; use type for unions, primitives, tuples, and computed types. The formatter treats both identically — both get a brace, indent, and one-member-per-line layout.
What are the conventions for spacing inside generics?
The Prettier / TSLint convention this formatter follows: no space inside the angle brackets (Array<string>, not Array< string >), one space after each comma in a multi-parameter list (Map<K, V>), and one space around the equals sign in a default (T extends string = "id"). Constraints use a space around extends (T extends string). The formatter normalises commas and equals; angle brackets are left as written.
Does the formatter preserve comments?
Yes. Single-line // comments, multi-line /* … */ blocks, and JSDoc /** … */ docstrings are preserved in place. They are emitted at the indent of the line they sit on. The formatter never strips, reorders, or splits comments — important for codebases that rely on JSDoc for type narrowing or for ESLint disable directives at the end of a line.
Does formatting change the compiled JavaScript?
No. TypeScript outside string and template-literal contexts is whitespace-insensitive. The compiler tsc emits identical JavaScript from formatted and unformatted source — the same tokens, the same AST, the same emit. The only thing that changes is human readability and the line-by-line diff in version control.
Does this handle TSX (React + TypeScript) files?
Yes. The brace-aware formatter does not interpret JSX as text — it follows the surrounding curly braces, so a return ( <Component prop={value} /> ) gets indented as a function body and the JSX is left intact. For deeper JSX-specific reformatting (attribute wrapping, self-closing normalisation), Prettier remains the better choice.
How is this different from running Prettier?
This is a lightweight pretty printer — it preserves your token order and only adjusts indent and brace placement. Prettier is opinionated: it re-prints the entire AST, normalises quote style, enforces line length, applies trailing commas, and splits long expressions across multiple lines. For a one-off readability pass on a snippet, this tool is faster. For project-wide enforcement, configure Prettier with a .prettierrc and a pre-commit hook so every file is normalised before it lands in the repo.
Will it handle decorators and the experimental decorator metadata?
Yes. Decorators on classes (@Component({…})), methods (@Get("/users")), and parameters (constructor(@Inject(TOKEN) svc: Service)) are formatted on their own line above the decorated declaration when they sit at indent level zero of the body. The new ECMAScript decorators proposal and the legacy experimentalDecorators flag use the same surface syntax, so both are handled.
Is the TypeScript I paste sent to your servers?
No. Formatting runs entirely in JavaScript on your machine. Code containing API keys, proprietary algorithms, or unreleased TypeScript features never leaves your browser. Open DevTools → Network and click Format to confirm no requests are made.