From d5044e42ea9c32623d636ba61f5c63a048b7aa4e Mon Sep 17 00:00:00 2001 From: Lewis Pollard Date: Mon, 26 Oct 2020 21:54:19 +0000 Subject: [PATCH 1/3] Update README with code completion hints Modified the Typescript section to also reference JSX code completion, with instructions on how to add the definitions .ts file to the package.json for JSX code completion support. --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d5f88f3..9985185a 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 godot.d.ts file is generated by the above steps. +- Code completion in JSX in VS Code can be achieved by adding `"types": "./godot.d.ts"` to your package.json file, as long as the godot.d.ts file is above or in a sibling folder of the .jsx source files in the directory structure. + #### 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. From 4eb5dcc65fe67595b855c89e241796aee2d91a47 Mon Sep 17 00:00:00 2001 From: Lewis Pollard Date: Mon, 26 Oct 2020 21:57:47 +0000 Subject: [PATCH 2/3] Add types def to package.json --- misc/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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" } From a8cd336c299c25244d24af2a7c859f92bb702609 Mon Sep 17 00:00:00 2001 From: Lewis Pollard Date: Mon, 26 Oct 2020 22:04:45 +0000 Subject: [PATCH 3/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9985185a..f0a041e6 100644 --- a/README.md +++ b/README.md @@ -158,8 +158,8 @@ Label.Align.ALIGN_LEFT | godot.Label.Align.ALIGN_LEFT - 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 godot.d.ts file is generated by the above steps. -- Code completion in JSX in VS Code can be achieved by adding `"types": "./godot.d.ts"` to your package.json file, as long as the godot.d.ts file is above or in a sibling folder of the .jsx source files in the directory structure. +- 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