{"id":26520,"library":"ts2gd","title":"ts2gd","description":"ts2gd is a TypeScript-to-GDScript transpiler for Godot 3.x projects, currently at version 0.0.36. It compiles TypeScript source files directly to GDScript with near-zero runtime overhead and fast incremental compilation (<0.1 seconds after startup). Unlike embedded JavaScript runtimes (e.g., GodotJS), ts2gd outputs native GDScript, ensuring no performance penalty. It enhances developer experience with full TypeScript type safety, autocomplete, and refactoring support. The project is in early beta with occasional breaking changes due to its pre-1.0 status. Development appears active, with updates every few months.","status":"active","version":"0.0.36","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install ts2gd","lang":"bash","label":"npm"},{"cmd":"yarn add ts2gd","lang":"bash","label":"yarn"},{"cmd":"pnpm add ts2gd","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CLI command to scaffold a new ts2gd project; not a programmatic import.","wrong":"npm init ts2gd","symbol":"init project","correct":"ts2gd --init"},{"note":"Running `ts2gd` without flags starts watch mode; `--buildOnly` compiles once.","wrong":"ts2gd --watch","symbol":"compilation (watch mode)","correct":"ts2gd"},{"note":"Use `--buildOnly` to compile all source files once and exit.","wrong":"ts2gd --build","symbol":"compilation (single build)","correct":"ts2gd --buildOnly"}],"quickstart":{"code":"// Install globally\nnpm install --global ts2gd\n\n# Initialize a new project\ncd my-godot-project\nts2gd --init\n\n# Write a TypeScript script (e.g., src/MyScript.ts)\nimport { Node2D, Input, KeyList } from \"godot\"\n\nexport default class MyScript extends Node2D {\n    _ready(): void {\n        if (Input.is_key_pressed(KeyList.KEY_SPACE)) {\n            print(\"Space pressed!\")\n        }\n    }\n}\n\n# Compile\n# Watch mode:\nts2gd\n# One-time build:\nts2gd --buildOnly","lang":"typescript","description":"Installs ts2gd globally, initializes a Godot project, writes a basic TypeScript script, and compiles it to GDScript."},"warnings":[{"fix":"Import the scene global directly (e.g., `import { MySceneTscn } from \"godot\"`) and use `instance()` instead of `preload()`","message":"Scene globals (e.g., MySceneTscn) are automatically created and exported; no need to preload","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `EnumName.Property` syntax; see generated `@globals.d.ts` for full list","message":"Enums are namespaced under enum name (e.g., `KeyList.KEY_SPACE`), not global scope","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Declare `$my_signal!: Signal` (use `!` to avoid TS uninitialized error)","message":"Signals must be declared as class properties with `$` prefix and type `Signal`","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add `@autoload` decorator to class, then `export const MyAutoload = new MyAutoloadClass()`","message":"Autoload classes require `@autoload` decorator and an exported instance","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Call `this.methodName.rpc(arg)` instead of `this.rpc(\"methodName\", arg)`","message":"`rpc` calls use method-chaining syntax: `this.my_rpc_method.rpc(\"arg\")` instead of `this.rpc(\"my_rpc_method\", \"arg\")`","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Godot to 3.3 or later, or avoid autoload exports","message":"Godot 3.3+ is required for autoload export functionality","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Lock version in package.json, test compilations after updates","message":"TS2GD is in early beta (v0.0.36); breaking changes may occur without major version bump","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Import KeyList from 'godot': `import { KeyList } from 'godot'`","cause":"Enum namespacing; KeyList is not globally scoped","error":"Cannot find name 'KeyList'"},{"fix":"If using a built-in signal, ensure the class extends the correct node type; for custom signals, declare `$my_signal!: Signal`","cause":"Signals must be declared in class definition with `$` prefix","error":"Property '$pressed' does not exist on type 'Button'"},{"fix":"Run `ts2gd --init` to scaffold project and generate types, or run `ts2gd --buildOnly` to generate `@globals.d.ts`","cause":"Missing generated type definitions; ts2gd --init or compilation hasn't run yet","error":"Cannot find module 'godot' or its corresponding type declarations"},{"fix":"Add `@remote` or `@remotesync` decorator to the method","cause":"Method is not marked as remote/rpc in GDScript; ts2gd uses `@remote`/`@remotesync` decorator","error":"TypeError: this.my_rpc_method.rpc is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}