PitchHut logo
svelte-check-native
A fast CLI type-checker for Svelte projects, built with Rust.
Pitch

svelte-check-native is designed for performance, offering a blazing fast type-checking experience for Svelte projects. Serving as a drop-in replacement for svelte-check, it retains all existing flags and output formats. Ideal for integrating into CI/CD pipelines or pre-commit hooks, it leverages Rust and tsgo for efficiency.

Description

svelte-check-native

svelte-check-native is a high-performance command-line interface (CLI) type-checker specifically designed for Svelte projects. It serves as a drop-in replacement for svelte-check, maintaining compatibility with the same flags, output formats, and exit codes. This tool is built with Rust and leverages tsgo, making it ideal for:

  • AI agents that require rapid feedback loops
  • Efficient CI/CD pipelines
  • Reliable Git pre-commit hooks

What it is and what it isn't

It isIt isn't
A CLI type-checker for Svelte 4 and 5An LSP / editor integration
A drop-in for svelte-check (flags + output)A CSS linter
A single Rust binary, powered by tsgoA formatter
Provides byte-identical diagnostics upstream
Supports incremental checking via tsgo's tsbuildinfo

Performance

When tested on a SvelteKit + TypeScript monorepo containing 1,359 .svelte files, the performance metrics are as follows:
Command executed: svelte-check-native --tsconfig tsconfig.json --diagnostic-sources 'js,svelte'

ToolColdWarmDirtySpeedupErrorsWarningsFiles w/ issues
svelte-check-native6.0 s2.6 s2.6 s15.8×14416
svelte-check 4.4.639.9 s41.0 s41.0 s1.0×14416
svelte-check-rs 0.9.715.0 s5.5 s4.4 s6.9×73244261

Installation

To install svelte-check-native, execute the following command:

npm i -D svelte-check-native @typescript/native-preview

The package @typescript/native-preview denotes the tsgo binary, essential for the checking process.

Usage

To utilize svelte-check-native, run:

npx svelte-check-native --workspace .

Alternatively, script it into your package.json:

{
  "scripts": {
    "check": "svelte-check-native --workspace ."
  }
}

This tool supports the same flags as svelte-check. For assistance, use:

npx svelte-check-native --help

How it Works

Flowchart of processing pipeline

The type-checking process involves:

  1. Parsing each .svelte file into script and template sections.
  2. Emitting a corresponding .svelte.ts overlay file.
  3. Executing tsgo against the overlay TypeScript configuration.
  4. Running the svelte/compiler for warnings via parallel processing.
  5. Mapping diagnostics back to the original .svelte file.

Flags and Environment Variables

Various flags are available for customized operation:

--workspace <path>
--tsconfig <path>
--output <fmt>
--threshold <level>
--fail-on-warnings
--diagnostic-sources <list>
--compiler-warnings <list>
--ignore <globs>
--color / --no-color
--timings
--debug-paths
--tsgo-version
--tsgo-diagnostics
--emit-ts

For detailed functionality, reviewing the output of svelte-check-native --help is recommended.

Additional environment variables may also influence the tool's behavior, such as TSGO_BIN for overriding tsgo discovery paths.

Troubleshooting

In case of stale errors after modifying tsconfig.json, the following command can be run to clear the cache:

rm -rf node_modules/.cache/svelte-check-native

Roadmap

Future features include CSS support for enhanced versatility.

For developers requiring speed and accuracy in type-checking their Svelte applications, svelte-check-native provides an efficient, Rust-optimized solution that seamlessly integrates into existing workflows.

0 comments

No comments yet.

Sign in to be the first to comment.