Skip to content

Suggest type constants as types #11430

Closed
godotengine/godot
#94996
@KoBeWi

Description

@KoBeWi

Describe the project you are working on

Complex GDScript-based project.

Describe the problem or limitation you are having in your project

GDScript supports using constants as types, e.g. const MyType = preload("res://script/path.gd") and afterwards var my_object: MyType etc. It's a nice feature if you don't want to pollute global namespace. However these "types" are not suggested in autocompletion, so e.g. if you write var my_object: MyT, the type won't be suggested.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It would be useful if type constants were available for autocompletion. Both local constants (MyType) and external ones (ClassName.MyType).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The editor is able to determine when to complete for type hint. "Constant types" are just constants of type Script, so they could be added to the type autocompletion list.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

Built-in autocompletion can't be extended.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions