What is the difference between JSX and TSX?
JSX is a syntax extension for JavaScript; TSX is the same syntax inside a TypeScript file. The .tsx extension tells the compiler to parse JSX while also accepting TypeScript constructs — interfaces, type aliases, generics, satisfies, as assertions, and decorators. The runtime output is identical: both compile to React.createElement (or jsx-runtime) calls. The TSX formatter knows about both.
How does the formatter tell a generic from a JSX tag?
A heuristic: < is treated as the start of a generic argument list when it directly follows an identifier character, ), ], or >. It is treated as the start of a JSX tag when it follows = , ( , , , { , } , ; , a newline, or the start of file, AND the next character is a letter or /. This matches the resolution order used by the TypeScript parser. Edge cases like Component<T> as a JSX tag with explicit type args are handled because the < follows a letter and the formatter falls through to JSX context only when surrounding code permits it.
Does it preserve satisfies, as casts, and angle-bracket assertions?
Yes. satisfies, as, and as const are kept as-is on the same line as their expression. Angle-bracket type assertions (<Foo>x) are not used inside .tsx files because they conflict with JSX — the TypeScript compiler itself rejects them. The formatter assumes idiomatic TSX (the as form) and does not rewrite assertion style.
Will the formatter add or remove type annotations?
No. The formatter is whitespace-only — it never inserts, removes, or rewrites a token. Annotations stay exactly as you wrote them. To add interfaces from inferred props, use the JSX to TSX tool instead.
Does it handle generic React components like <Select<Option> value={x} />?
Yes — explicit generic arguments on a JSX tag are recognised because the parser collects everything between the tag-name and the next > or />. The angle brackets inside the attribute area are part of the tag header, not nested JSX, so depth counting is not affected.
Why is some output different from Prettier?
This formatter is a lightweight tag-aware indenter — it preserves token order and only rewrites whitespace. Prettier re-prints the AST: it normalises quote style, enforces a print width, splits long expressions across lines, and applies trailing commas. For project-wide enforcement install Prettier and add a pre-commit hook. For one-off snippet readability, this tool is faster and runs without a build step.
Is the TSX I paste sent to your servers?
No. Formatting runs entirely in JavaScript inside your browser. Code containing API keys, proprietary algorithms, or unreleased features never leaves the device. You can verify this in DevTools → Network — no requests are made when you click Format.
Does it handle decorators on class components?
Yes. Decorators (@Component({ … }), @Inject(TOKEN)) are kept on their own line above the decorated declaration. The brace depth counter understands the decorator argument parentheses and braces correctly.