Kdts

an optimization-first TypeScript compiler

Last verified:

Visit Kdts

What is Kdts?

kdts is an optimization‑first TypeScript compiler that retains type information throughout compilation in order to guide aggressive size and performance optimizations. Instead of erasing types early like many traditional compilers, it keeps them to power transformations that can significantly reduce the size of frontend bundles, often producing output around 40 percent smaller than the best type‑unaware alternatives when the code is fully and accurately typed. This makes it especially useful for shipping compact, high‑performance JavaScript applications where bundle size directly affects loading performance and user experience.

kdts operates in two distinct modes: fast and opt. The fast mode wraps bun build and behaves like a standard build command, supporting any valid TypeScript input without requiring type analysis, but producing larger output. The opt mode uses a special fork of Google Closure Compiler as a backend, enabling advanced optimizations that depend on whole‑program type information, albeit at the cost of more limited TypeScript and JavaScript support and the need for correct type declarations in all npm packages used.

The tool is oriented toward TypeScript‑heavy codebases, especially those tightly integrated with KimlikDAO’s own ecosystem (for example, the kimlikdao‑lib library), and is designed for teams that prioritize bundle‑size reduction and runtime efficiency over strict TypeScript‑compatibility. It comes with a CLI that supports compilation, testing, and benchmarking flows (kdts run, kdts test, kdts bench), making it suitable for projects where the same compiler can be used uniformly across development, testing, and production builds.

Kdts pricing

Pricing model: Freemium

kdts is distributed as an open‑source package (@kimlikdao/kdts) and can be installed and used globally without any explicit paid plans or subscription tiers mentioned on the documentation site. The project does not list specific commercial licensing or pricing information, strongly suggesting that the tool is free to use as long as its source license terms are respected, though advanced or enterprise‑grade support is not advertised on the public docs.

Kdts pros

  • Produces significantly smaller frontend output than conventional type‑unaware compilers
  • Uses TypeScript types throughout compilation to enable optimizations not possible with erased types
  • Built‑in support for aggressive dead‑code elimination and minification via Closure Compiler backend
  • Two modes: fast for broad compatibility and opt for maximum optimization
  • Integrates with Bun, enabling fast incremental builds and modern tooling workflows
  • Supports whole‑program analysis starting from an entrypoint and crawling transitive dependencies
  • Can leave npm packages as ES6 imports instead of bundling them, improving cache efficiency
  • Provides CLI commands for build, test, and benchmark flows (kdts run, kdts test, kdts bench)
  • Works well on fully and accurately typed codebases, where optimization gains are biggest
  • Actively developed with frequent additions of missing TypeScript features and bug fixes
  • Examples and real‑world usage showcased in KimlikDAO’s own library code and sample projects
  • Encourages stricter type practices by rewarding fully typed code with better output
  • Can be extended with custom declaration shims for external npm packages
  • Open‑source and community‑contributable on GitHub
  • Well‑suited for shipping compact frontends where bundle size impacts UX and performance

Kdts cons

  • Experimental and not yet fuzzed on broad test suites, increasing risk for production use
  • Not a drop‑in replacement for tsc and explicitly not aiming to be one
  • Opt mode supports only a subset of TypeScript and may never support some language features
  • Some JavaScript features may be unsupported or behave differently in opt mode
  • Requires type declarations for every npm package used in opt mode, or custom shims
  • Limited set of pre‑built declaration shims for external libraries, so integration effort can be high
  • Implementation coverage for opt mode does not yet match the documentation everywhere
  • Tight coupling to Bun means it is not immediately usable with other Node‑based toolchains

Frequently asked questions about Kdts

What is kdts and how does it differ from tsc?

kdts is an optimization‑first TypeScript compiler that keeps type information throughout compilation in order to drive aggressive size and performance optimizations, whereas tsc erases types early and focuses on correctness and standard compatibility. As a result, kdts can produce much smaller output by leveraging whole‑program type‑aware transformations, but it is not designed to be a drop‑in replacement for tsc and may have different language‑feature support and behavior.

What are the fast and opt modes in kdts?

kdts offers two modes: fast and opt. The fast mode wraps bun build, runs without type checking, supports nearly any valid TypeScript, and produces larger output quickly. The opt mode uses a Closure Compiler fork as a backend, analyzes types across the entire program, and applies advanced optimizations that can shrink frontend bundles by roughly 40 percent compared to type‑unaware alternatives, but it only supports a subset of TypeScript and has stricter requirements on type declarations.

How do I install and run kdts?

kdts can be installed globally via bun add -g @kimlikdao/kdts, and it currently requires Bun as the underlying runtime. To use it, compile a program with kdts entry.ts --fast for the fast mode, or kdts entry.ts for the opt mode; both will crawl transitive dependencies and emit a single ES6 module to an output file such as entry.out.js. The same CLI can be used with kdts run, kdts test, and kdts bench to run, test, or benchmark TypeScript files.

Does kdts bundle npm packages?

By default kdts does not bundle npm packages but leaves them as ES6 imports, similar to the --packages external setting in many bundlers, which helps keep output smaller and improves caching. However, in opt mode the compiler still needs to discover type declarations for all imported packages in order to perform whole‑program optimization, even if the runtime code remains externalized.

Why does kdts need type declarations for npm packages?

In opt mode, kdts uses type information across the entire program, including imported npm packages, to guide optimizations and validity checks. If a package does not export parseable type declarations, kdts cannot properly analyze it and compilation may fail unless you provide declaration shims in a local @types/ directory or by contributing shims to the kdts/@types subtree on GitHub.

Is kdts safe for production use?

kdts is still experimental and has not been fuzzed on broad test suites, so there is some risk when using it in production. The authors state that fast mode should work on most valid TypeScript, but opt mode likely does not yet support large parts of the language and may never support everything; teams considering production use are encouraged to test thoroughly on their own codebases and monitor the project’s active development status.

What projects is kdts best suited for?

kdts is best suited for TypeScript‑heavy projects that prioritize small bundle size and runtime performance and where code can be kept fully and accurately typed. It is particularly well‑aligned with codebases that already use or are moving toward Bun as a runtime, and it is actively used inside KimlikDAO’s own library (kimlikdao‑lib) as a real‑world example of high‑optimization‑mode usage.

How can I contribute to kdts or add new features?

The project is open‑source and hosted on GitHub, where users can file issues, submit pull requests, and add declaration shims for npm packages. The documentation encourages community contributions both for language‑feature support and for expanding the set of known type declarations, so anybody familiar with TypeScript and Closure‑style optimization patterns can help extend opt mode coverage and improve compatibility.

What limitations does kdts have around TypeScript support?

kdts intentionally does not aim to fully replicate tsc or the full TypeScript language specification. The opt mode supports only a subset of TypeScript and may never support some features, and it has intentional differences such as treating classes and interfaces as nominal types and object types as structural. The documentation warns that implementation coverage still lags behind the spec, so some declared features may not yet be fully implemented.

How does kdts integrate with testing and benchmarking?

kdts provides dedicated CLI subcommands kdts run, kdts test, and kdts bench that compile and then execute TypeScript files; these can be used to run normal programs, tests, or benchmarks, and they accept the --fast flag when needed. This allows teams to keep the same compiler and optimization pipeline for development builds, testing runs, and performance benchmarks, ensuring consistency across the lifecycle of the codebase.

Use cases

Browse all AI tools on NeedAnAI