Editor setup
This page sets up two things. The TypeScript plugin shows converter and Godot errors while you type, and tstogd open-editor makes Godot open your .ts file when you double-click a script.
Errors as you type
Section titled “Errors as you type”typescript-to-gdscript ships a plugin for the TypeScript service that your editor already runs. It converts the file you are editing, even before you save, and shows two more kinds of errors next to the usual TypeScript ones:
-
Converter errors: code GDScript can’t express. For example,
??doesn’t exist in GDScript:TypeScript let text = this.label_text ?? 'Ready';// Nullish coalescing (`??`) is not supported in GDScript -
Godot errors: Godot checks the generated script in the background, and its errors show up a moment later on the matching
.tsline.
tstogd init turns the plugin on in tsconfig.json:
{ "compilerOptions": { "plugins": [{ "name": "typescript-to-gdscript/ts-plugin" }] }}Make sure the plugin is loaded
Section titled “Make sure the plugin is loaded”The plugin only loads when the editor uses the project’s own TypeScript from node_modules/typescript, not the copy bundled with the editor.
- VS Code: open any
.tsfile, run TypeScript: Select TypeScript Version… from the Command Palette, and choose Use Workspace Version. - WebStorm: in Settings → Languages & Frameworks → TypeScript, set TypeScript to
node_modules/typescriptand keep TypeScript Language Service on. Then restart the TypeScript service (File → Invalidate Caches → Just Restart always works).
To check it works, write ?? in a method, as in the example above. If the converter error appears under it, the plugin is running.
Note: Changes to
tsconfig.json, including the plugin options, take effect only after the TypeScript service restarts. In VS Code, run TypeScript: Restart TS Server.
To keep the converter errors but skip the Godot check in the editor only, add "disableGodotLint": true to the plugin entry:
{ "compilerOptions": { "plugins": [ { "name": "typescript-to-gdscript/ts-plugin", "disableGodotLint": true } ] }}Open your .ts from Godot
Section titled “Open your .ts from Godot”Godot opens scripts in its own editor by default, and there you would see the generated .gd. Point Godot at tstogd open-editor instead. It finds the .ts file for the .gd, maps the line with the source map, and starts your editor there.
In Godot, open Editor Settings → Text Editor → External and set:
-
Use External Editor: on.
-
Exec Path:
tstogdif it is on yourPATH, otherwise its full path. For a project install that isnode_modules/.bin/tstogdin your project (tstogd.cmdon Windows). -
Exec Flags:
open-editor -f "{file}" -l {line} -c {col} -p "{project}" -e "code --goto {tsFile}:{tsLine}:{tsCol}"
Godot fills in {file}, {line}, {col} and {project}. tstogd fills in {tsFile}, {tsLine} and {tsCol} and runs the command after -e. Keep the quotes around {file} and {project} so paths with spaces work.
The -e part depends on your editor:
| Editor | -e value |
|---|---|
| VS Code | -e "code --goto {tsFile}:{tsLine}:{tsCol}" |
| WebStorm | -e "webstorm --line {tsLine} --column {tsCol} {tsFile}" |
| Rider | -e "rider --line {tsLine} --column {tsCol} {tsFile}" |
Note: tstogd starts the editor directly, without a shell. On Windows that means
codeand other.cmdlaunchers don’t start. Put the full path to the editor’s.exein-einstead.
Also turn on Editor Settings → Text Editor → Behavior → Auto Reload Scripts on External Change. Then Godot picks up each regenerated .gd without asking.
Debugging
Section titled “Debugging”Godot’s debugger reports errors and stack frames at .gd lines. Opened through open-editor, they land on the matching .ts line instead.
The external-editor setting covers double-clicks in the FileSystem dock, but not the Debugger panel. For clicks on errors and stack frames to open your .ts too, switch to the Script screen and turn on Debug with External Editor in its Debug menu. While it is off, those clicks never reach open-editor.
Details
Section titled “Details”IDE integration covers the plugin options and diagnostics in full, and the open-editor reference lists its flags.
