-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x] get_node()
overrides autocompletion information for statically typed variables
#53318
Comments
get_node()
overrides type hints in the editor
Looks similar to #39228 |
Ar not we supposed to do a kind of typecast to the node, since var node_variable: Node2D = get_node(<NodePath>) as Node2D Edit: I suppose that when you do |
If you provide type for variable, it should be treated like of this type, without any need for casting. If it doesn't, it's a bug (it makes type hints pointless). |
So i found some more context to this issue. This might be of use to you:
# godot autocompletes the play() function if it can resolve the path to a node in the currently open scene
$AnimationPlayer.play() This is a nice feature for those using dynamic typing. But the weird part is that this information overrides the autocompletion information provided by static types. export var target_path: NodePath
# target is of type node2D, but provides autocompletion suggestions for Node
onready var target: Node2D = get_node(target_path)
func _physics_process(delta: float) -> void:
# target.position not suggested by autocomplete
# Godot does not raise an UNSAFE_PROPERTY_ACCESS warning, which means that the type works, just not in autocompletion
print(target.position)
# play() method doesn't exist on Node2D, Godot raises an UNSAFE_METHOD_ACCESS warning as expected
target.play()
|
get_node()
overrides type hints in the editorget_node()
overrides autocompletion information for statically typed variables
Seems to be the same as #42005. |
This seems fully fixed on current master. |
get_node()
overrides autocompletion information for statically typed variablesget_node()
overrides autocompletion information for statically typed variables
Godot version
3.3.stable
System information
OS: Windows 10
Issue description
When I provide a type hint to a node from
get_node
, my type hint gets overridden by get_node. this only happens in the editor. Ingame the types work as expected. Forgive me if this is the intended behavior, but is just seems odd to me.This becomes relevant when using get_node with NodePaths provided from the Inspector, And the editor doesn't provide correct autocompletion.
Steps to reproduce
Minimal reproduction project
GetNodeTypeIssue.zip
The text was updated successfully, but these errors were encountered: