typescript-to-javascript
v2.0.0
Published
A CLI tool that converts TypeScript projects to plain JavaScript by stripping type annotations and rewriting import extensions. Uses Babel to transpile `.ts` → `.js` and `.tsx` → `.jsx`, then runs a Claude Code agent to clean up config files in the output
Readme
typescript-to-javascript
A CLI tool that converts TypeScript projects to plain JavaScript by stripping type annotations and rewriting import extensions. Uses Babel to transpile .ts → .js and .tsx → .jsx, then runs a Claude Code agent to clean up config files in the output directory.
Install
npm i -g typescript-to-javascriptRequires Bun to be installed on your system.
Usage
Run from the root of any TypeScript project:
tsx-js [source-dir] [output-dir]| Argument | Default | Description |
|---|---|---|
| source-dir | client | Directory containing TypeScript source files |
| output-dir | <source-dir>-js | Directory where JavaScript output is written |
Examples
# Convert ./client → ./client-js
tsx-js
# Convert ./src → ./src-js
tsx-js src
# Convert ./app → ./app-output (custom output name)
tsx-js app app-outputWhat it does
- Transpiles
.tsfiles →.jsusing@babel/preset-typescript(strips all type annotations) - Transpiles
.tsxfiles →.jsxusing@babel/preset-typescript+@babel/plugin-syntax-jsx(preserves JSX, strips types) - Rewrites relative imports — updates
.ts/.tsxextensions inimportstatements to their.js/.jsxequivalents - Runs a Claude Code agent to copy and update non-TypeScript project files (
package.json, config files, etc.) in the output directory — removing TS-only deps and adjusting scripts for JavaScript
The Claude Code post-conversion step requires the
claudeCLI to be available. If it is not found, the step is skipped and a warning is printed.
Requirements
- Bun runtime
- Claude Code CLI (
claudeon PATH) — optional, for the config cleanup step
Local development
bun install
bun run convert