typegone
v1.2.2
Published
Convert TypeScript to plain JavaScript by stripping all types and JSDoc annotations.
Downloads
135
Maintainers
Readme
🧨 typegone
TypeScript is just JavaScript in a cosplay.
typegonemakes it real again.
typegone is a source-to-source transformer tool that replaces all TypeScript type annotations with any, or removes them entirely, including types from JSDoc — effectively turning your TypeScript back into plain JavaScript.
It can also add any to untyped JavaScript parameters, effectively converting plain JS to TypeScript with any everywhere.
🚀 Features
- ✅ Replace all existing type annotations (
: string,: number, etc.) withany - ✅ Add
: anyto untyped function parameters - ✅ Convert
as Somethingtoas any - ✅ Remove generics like
<T> - ✅ Convert or remove JSDoc
{type}annotations - ✅ Optionally remove all type annotations entirely (turn TypeScript into pure JavaScript)
- ✅ Support file-based config (
typegone.config.js) - ✅ Non-destructive: Only types are removed, logic stays the same
🔧 Usage
1. Install
npm install -D typegone2. Configuration - Create a typegone.config.* file
TypeGone will automatically detect a configuration file named typegone.config with one of the following extensions:
.ts,.js,.cjs,.mjs
📍 Important: This file must be located at the root of your project (next to your
package.json).
For example:
typegone.config.tstypegone.config.jstypegone.config.cjstypegone.config.mjs
You can define your config using either:
- A plain object
- Or with the helper
defineTypegoneConfig(recommended for better DX in TypeScript)
✅ Example: typegone.config.js (ESM)
Using defineTypegoneConfig (recommended)
import { defineTypegoneConfig } from "typegone";
export default defineTypegoneConfig({
include: ["src/**/*.{ts,tsx}"],
exclude: ["**/node_modules/**", "**/dist/**"],
overwrite: false,
outDir: "./typegone", // Output folder with same structure
convertJsDoc: true, // Convert `{string}` → `{any}` in JSDoc
removeJsDocType: false // If true, remove all JSDoc types entirely
});Or just a plain object (works too)
export default {
include: ["src/**/*.{ts,tsx}"],
exclude: ["**/node_modules/**", "**/dist/**"]
};✅ Example: typegone.config.cjs (CommonJS)
Using defineTypegoneConfig
const { defineTypegoneConfig } = require("typegone");
module.exports = defineTypegoneConfig({
include: ["src/**/*.{ts,js}"],
exclude: ["**/node_modules/**", "**/dist/**"]
});Or plain object export
module.exports = {
include: ["src/**/*.{ts,tsx}"],
exclude: ["**/node_modules/**", "**/dist/**"]
};3. Run it
npx typegoneIt will auto-detect your config file and apply transformations.
🧪 Example
Before:
interface User {
name: string;
age: number;
}
/**
* @param {string} name
* @returns {number}
*/
function greet(name: string): number {
return name.length;
}After:
interface User {
name: any;
age: any;
}
/**
* @param {any} name
* @returns {any}
*/
function greet(name: any): any {
return name.length;
}⚙️ Configuration Options
| Option | Type | Description |
|--------------------|-----------|------------------------------------------------------------------------------|
| include | string[] | Glob patterns to include (default: src/**/*.{ts,tsx}) |
| exclude | string[] | Glob patterns to exclude |
| overwrite | boolean | Overwrite original files with modified ones (use with caution) |
| verbose | boolean | Log each file being changed |
| convertJsDoc | boolean | Replace JSDoc {type} with {any} |
| removeJsDocType | boolean | Remove all JSDoc comments that declare types (e.g. @param, @returns) |
| stripTypes | boolean | Remove all type annotations instead of replacing them with any |
| outDir | string | Output directory. Files will be written here with the same folder structure |
🤔 Why would you use this?
- Migrate a legacy JavaScript project to TypeScript with permissive
anyeverywhere (for gradual typing). - Convert a TypeScript codebase back to plain JavaScript for faster prototyping or delivery.
- Strip types before bundling or passing code to tools that don't support TypeScript.
- Generate raw, untyped output for AI models, code analysis, or codegen pipelines.
- Or just troll your teammates on a Friday. (Use at your own risk)
📦 Changelog
See full release notes in CHANGELOG.md
📄 License
MIT © 2025 — Made with ❤️ by @yukiakai
