diff --git a/README.md b/README.md index 1d5f88f3..f0a041e6 100644 --- a/README.md +++ b/README.md @@ -153,10 +153,14 @@ Label.Align.ALIGN_LEFT | godot.Label.Align.ALIGN_LEFT } ``` -### TypeScript support +### TypeScript support and JSX code completion - Run the menu command `Project > Tools > ECMAScript > Generate TypeScript Project` from the godot editor to generate a TypeScript project - Run `tsc -w -p .` under your project folder in the terminal to compile scripts +#### Code completion +- Code completion in TSX will automatically work once the TypeScript project is generated by the above steps. +- Code completion in JSX in VS Code is achieved by the property `"types": "./godot.d.ts"` in the generated package.json file of the TypeScript project. The `godot.d.ts` file can be generated alone via the `Project > Tools > ECMAScript > Generate TypeScript Declaration File` editor menu option and added to a `package.json` file manually to achieve this without a full TypeScript project. + #### Example TypeScript Usage Make sure the file with extension '.tsx' so it can be compiled to a `.jsx` file then we can attach it to a node in godot editor. diff --git a/misc/package.json b/misc/package.json index 05c1c09f..88c2e7d0 100644 --- a/misc/package.json +++ b/misc/package.json @@ -5,5 +5,6 @@ }, "devDependencies": { "typescript": "^3.9.7" - } + }, + "types": "godot.d.ts" }