How to use TypeScript Formatter
Clean up the layout of TypeScript source for reading or review. The browser formatter retains type syntax instead of compiling it to JavaScript.
- Paste TypeScript or open a file, choose Indentation and format.
- Review output against the conventions of the project that will receive it.
Example input
const label: string = "Field Notes"; export const copies: number = 12;
Example use
Make a generated type alias or a large type definition easier to compare in a review.
Output and compatibility
Formatting does not type-check modules or follow imports. TypeScript dialect features need support from the bundled source parser.
Troubleshooting
If a syntax error persists, try a smaller source excerpt to isolate the unsupported or malformed construct.
Use JSON to TypeScript when drafting types from a sample JSON value.
Frequently asked questions
Does it remove TypeScript types?
It formats TypeScript source. Use TypeScript to JavaScript for transpilation.
Does it validate imported types?
It does not load the rest of your project.