TypeScriptToGdScript is a TypeScript to GDScript transpiler for Godot 4, allowing you to write code in TypeScript and generate native Godot scripts!
Large GDScript projects can become hard to maintain and prone to errors. Writing in TypeScript improves code readability, maintainability, and reliability, while also benefiting from powerful tools like ESLint, Prettier, and IDE support (such as Visual Studio Code and WebStorm).
This project makes working with Godot easier, enabling the use of existing Godot APIs simply by declaring them through TypeScript.
-
Clone the Repository
git clone https://github.com/GeTechG/TypeScriptToGdScript.git
-
Install Dependencies
npm install
-
Build the Project
npm run build
-
Link the Local Package
npm run local-link
-
Initialize the Project
Open the console in your project folder and initialize the TypeScriptToGdScript (tstgd) project.
tstgd init
-
Configure the Project
Update the
tstgd.jsonfile, specifying the directories for source TypeScript files (src) and output GDScript files (out):{ "src": "src", "out": "out" } -
Generate Godot Declaration Files (Optional)
To enhance your development experience, generate Godot declaration files by running the following command. Be sure to provide the path to the Godot engine's source directory:
tstgd lib <path to godot source>
This step helps integrate TypeScript more seamlessly with Godot's native APIs.
-
Transpile TypeScript to GDScript
Run the transpiler:
tstgd
Enjoy writing your Godot 4 projects in TypeScript with better tooling and maintenance!
