Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.06 KB

README.md

File metadata and controls

50 lines (34 loc) · 1.06 KB

js-to-ts-converter

A tool to automatically convert JavaScript code to TypeScript using large language models (e.g., OpenAI's GPT-4).

Features

  • 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

Installation

  1. Clone the repository:

    git clone https://github.com/jaafarskafi1/js-to-ts-converter.git
    cd js-to-ts-converter
  2. Install dependencies:

    npm install
  3. 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

Usage

  1. Run the converter:

    node src/index.js convert path/to/your/javascript-file.js
  2. The converted TypeScript file will be created in a new directory with a .ts extension.

Example

Convert a directory's js files:

node src/index.js convert your_directory_name