Inlay hints for GDScript #7683
Replies: 5 comments 4 replies
-
If you only use type inference when the type is "explicitly written" on the right side of the assignment the hint would have no advantage, right? |
Beta Was this translation helpful? Give feedback.
-
it's a nice idea, although the syntax showcased in the examples, while gdscript-looking, would be problematic here since var x: bool = true means that var x = true would be misleading since in that case, |
Beta Was this translation helpful? Give feedback.
-
Personally, I don't like fake elements (such as ligatures and inlay hints) in text editors and IDEs. This is more of an editor feature than a GDScript feature. We recently added a warning for untyped declarations (disabled by default). The next step is to add a warning that will require explicitly specified static types. |
Beta Was this translation helpful? Give feedback.
-
With this inlay display feature to CodeEdit node, is it possible to make add-ons like github copilot in Godot? I check an existed Godot Copilot but it can't have ai code completion like in vscode due to current CodeEdit node lacking this feature. |
Beta Was this translation helpful? Give feedback.
-
Since starting to use Godot I've been pleasantly surprised with how useful GDScript has been. Especially seeing the new type work that has happened is very encouraging.
One aspect which I feel would greatly increase ease of use for new and experienced users would be inlay hints. I assume the compiler already has the type information needed to show these as it uses them to show errors in the editor.
Inlay hints show the inferred type of a variable without the user having to explicitly write it. This is especially useful with constructs like
var foo =
orvar foo :=
when calling engine functions which the user might not know the return type of. This avoid having to frequently check the docs or hover the function call to see what it returns.JS example
Rust example
You can find inlay hints in most editors these days and they dramatically improve readability.
Existing examples in different editors: Vscode, IntelliJ, Neovim
Beta Was this translation helpful? Give feedback.
All reactions