A tool to automatically convert JavaScript code to TypeScript using large language models (e.g., OpenAI's GPT-4).
- Convert JavaScript code to TypeScript
- Leverages OpenAI's GPT-4 for accurate conversion
- Command-Line Interface (CLI) for easy use
- Automatically handles common TypeScript conversions and annotations
-
Clone the repository:
git clone https://github.com/jaafarskafi1/js-to-ts-converter.git cd js-to-ts-converter
-
Install dependencies:
npm install
-
Set up OpenAI API key:
- Sign up for the OpenAI API and get your API key.
- Create a
.env
file in the root directory and add your API key:OPENAI_API_KEY=your_openai_api_key_here
-
Run the converter:
node src/index.js convert path/to/your/javascript-file.js
-
The converted TypeScript file will be created in a new directory with a
.ts
extension.
Convert a directory's js files:
node src/index.js convert your_directory_name