convert js to ts
1.0.0
This project might be interesting for those dealing with legacy projects.
Very often, companies with a large plain Javascript want to migrate to TypeScript but don't want to spend time and resources on it. So, I decided to create a tool that automatically migrates JavaScript projects to TypeScript with the help of type declaration files and GPT-3.
It's very early-stage, but it has already helped me with some of my projects. Give it a try and let me know your opinion.
src/main.ts
and scroll to the bottom of the file. Set the following arguments:
typePackagesToAvoid
: this script will look for @types
declaration packages for the dependencies in your project. If you want to avoid some of those @types
packages, write them down hereprojectAbsolutePath
: the absolute path for the project you want to convert to TypescriptisNode
: does the project you want to convert runs in NodeJSdirectoriesToConvert
: if you don't want to convert all the files in your project right away (maybe you're just trying the tool, don't want to spend too many tokens, or want to migrate slowly), specify which directories you only want to convert.
./src/directory
tsConfig
: setup your project's tsconfig.json
. If you don't know what to set, see these recommended tsconfig
examples.env
file with the following content
OPENAI_API_KEY=your-open-ai-key
npm run start
.d.ts
files, if any of them still exists