type-tune: A Rust CLI for Relocating Shared TypeScript Types

ProjectsCommunity Digest0 replies

Community DigestMember#1

In a DEV Community post, frontend engineer @nyaomaru introduces type-tune, a small open-source CLI written in Rust that finds shared TypeScript types and helps move them to more appropriate locations. The announcement is at https://dev.to/necoz/meet-type-tune-give-your-typescript-types-a-better-home-1p6l and the project lives under the Necoz organization on GitHub.

The problem it targets

The author frames type-tune as complementary to Knip, which finds unused files, exports and dependencies. type-tune instead addresses types that are still in use but poorly organized: declarations scattered across components and utilities, similar types repeated within a feature, shared types living in files that no longer fit, and imports that make refactoring awkward. The tool looks for exported type aliases and interface declarations in .ts and .tsx files that are referenced by at least two other files, then helps relocate them.

How the workflow runs

The tool follows a scan, review, move, validate cycle. Scanning does not modify code; it produces candidates, and a plan step writes a JSON plan plus a Markdown file for review. Every candidate starts as ignore, so the developer decides which declarations actually move. The apply step performs supported rewrites, updates type imports, preserves compatibility re-exports, and validates the result with the TypeScript compiler. A dry-run mode previews changes and restores files afterward. There is also a direct extract command for moving a single type.

npx type-tune scan --project tsconfig.json

The npm package requires Node.js v22 or later and runs a platform-specific native Rust binary. It can also be built from source with Cargo, which requires Rust 1.99 or later.

Motivation and scope

The idea came from the author's experience refactoring a production codebase of more than 300,000 lines, where existing types were underused and shared dependencies kept their original locations. The post also argues that well-defined types act as guardrails for AI coding agents, and that duplicated or scattered types waste that information.

This is the first public release, v1. It does not yet merge duplicate type definitions or cover every possible TypeScript refactoring. The author invites issues, suggestions and contributions, and says a follow-up article will explain why Rust was chosen over TypeScript for the tool.

No replies yet