AutoTypeX VS Code Extension 🚀
Automatically infer TypeScript types from JavaScript objects!
🔹 AutoTypeX
is a VS Code extension that dynamically analyzes selected JavaScript objects and generates TypeScript type definitions, inserting them directly into your editor.
Perfect for developers migrating from JS to TS or handling dynamic data structures.
📦 Installation
From the VS Code Marketplace
- Open VS Code.
- Go to Extensions (
Ctrl+Shift+X
).
- Search for "AutoTypeX".
- Click Install.
Manual Installation
If you have the .vsix
package:
code --install-extension autotypex-vscode.vsix
🚀 Usage
1️⃣ Select a JavaScript Object
Select the object in your editor:
const user = {
id: 1,
name: "Alice",
isActive: true
};
2️⃣ Run the Command
Press Ctrl + Shift + P
(or Cmd + Shift + P
on Mac)
Then select "Infer TypeScript Type from Object".
3️⃣ Output
The extension inserts the inferred TypeScript type into your file:
interface InferredType {
id: number;
name: string;
isActive: boolean;
}
🛠 Features
✅ Infer TypeScript types from JavaScript objects.
✅ Supports nested objects and arrays.
✅ Converts functions to () => void
.
✅ Works with both JavaScript and JSON objects.
✅ Integrated directly into VS Code (no need to copy-paste).
🔧 Settings & Customization
Setting |
Default |
Description |
autotypex.formatOutput |
true |
Format the output TypeScript interface |
autotypex.typeName |
"InferredType" |
Set a default type name |
autotypex.saveToFile |
false |
Automatically save inferred type to a .d.ts file |
Modify settings via:
- File → Preferences → Settings → Search
"autotypex"
- Or edit
settings.json
manually.
🎯 Example Scenarios
Nested Objects
const user = {
profile: {
firstName: "Alice",
age: 25
}
};
✅ Output:
interface InferredType {
profile: {
firstName: string;
age: number;
};
}
Arrays
const data = { tags: ["JS", "TS"] };
✅ Output:
interface InferredType {
tags: string[];
}
Functions
const obj = { log: () => console.log("Hello") };
✅ Output:
interface InferredType {
log: () => void;
}
📜 License
MIT License © 2025 Rashad
🌟 Contributing
Contributions are welcome! Feel free to submit an issue or pull request.
🚀 Happy Coding!