javascriptconverter-cli
v0.1.0
Published
Command-line interface for javascriptconverter.com — convert JavaScript files or directories to TypeScript via the public API.
Maintainers
Readme
javascriptconverter-cli
Command-line interface for javascriptconverter.com. Converts JavaScript files or directories to TypeScript via the public API.
How your code is handled
This is a hosted converter. Each file you convert is sent over HTTPS to
javascriptconverter.com (or to the --api URL you provide), converted there, and the
TypeScript is returned. Your source code leaves your machine. If your code cannot be
sent to a third-party service, run your own instance of the conversion engine and point
the CLI at it with --api http://localhost:3101 — nothing is sent anywhere else, and
--dry-run makes no network calls at all.
Install
npm install -g javascriptconverter-cliOr run without installing:
npx javascriptconverter-cli src/Usage
javascriptconverter <input> [-o <output>] [options]Examples
Convert a directory:
javascriptconverter src/ # writes to ./src.ts-output/
javascriptconverter src/ -o dist-ts # writes to ./dist-ts/Convert a single file:
javascriptconverter app.js -o app.tsPoint at a self-hosted API or local dev:
javascriptconverter src/ --api http://localhost:3101
JSC_API_URL=https://api.example.com javascriptconverter src/Preview without making API calls:
javascriptconverter src/ --dry-runOptions
| Flag | Default | Notes |
| --- | --- | --- |
| -o, --output <path> | <input>.ts-output | File or directory. |
| --api <url> | https://javascriptconverter.com | Or set JSC_API_URL. |
| --concurrency <n> | 4 | Parallel HTTP requests. |
| --include-tests | off | Include *.test.*, *.spec.*, __tests__/. |
| --dry-run | off | List planned conversions, no API calls. |
| -h, --help | | Show help. |
| -v, --version | | Print version. |
What's skipped
node_modules,dist,build,.git,.next,.cache,coverage,outdirectories- Hidden directories (anything starting with
.) - Test files matching
*.test.*,*.spec.*, or under__tests__/— pass--include-teststo convert them too - Files larger than 50,000 characters — split them before converting
File extension mapping
| Input | Output |
| --- | --- |
| .js | .ts |
| .cjs | .ts |
| .mjs | .ts |
| .jsx | .tsx |
Limits
The free public API has a per-conversion limit of 50,000 characters. Files exceeding this are reported as failed; the rest of the run continues.
For larger projects (whole-repo batch ZIP, configurable strict mode / module system / tsconfig generation), use the web converter which supports paid tiers.
Build from source
npm install
npm run build
node dist/cli.js src/License
MIT
