introduction #

tsv is a formatter, parser, and future linter + more for TypeScript, Svelte, and CSS. This is an early release, but it's ready for testing and feedback. It probably won't mangle your code!

Install
#

tsv ships as WASM packages on npm, a CLI with a formatter and parser:

npm i -D @fuzdev/tsv_wasm npx tsv format src npx tsv parse src/foo.svelte

For smaller builds, the formatter and parser also ship solo:

npm i -D @fuzdev/tsv_format_wasm npm i -D @fuzdev/tsv_parse_wasm

See the benchmarks for size and performance details.

Native builds are not yet available -- opening an issue would help push that along.

Usage
#

All three packages share the same API. The full package exports both halves:

import {format_svelte, parse_svelte, type Root} from '@fuzdev/tsv_wasm'; const formatted = format_svelte('<script>\nconst x=1\n<\/script>'); const ast: Root = parse_svelte('<script>const x = 1;<\/script>');

The formatter alone:

import {format_svelte} from '@fuzdev/tsv_format_wasm'; const formatted = format_svelte('<script>\nconst x=1\n<\/script>');

The parser alone:

import {parse_svelte, type Root} from '@fuzdev/tsv_parse_wasm'; const ast: Root = parse_svelte('<script>const x = 1;<\/script>');

format_typescript, format_css, parse_typescript, and parse_css work the same way, and the parsers return Svelte-compatible JSON ASTs with bundled TS types. Everything works zero-config in Node.js, Bun, and Deno (sync auto-init); browsers and bundlers call await init() once first.

Source code
#