How do I export TypedArray in Godot4 c++ module?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hidemat

Does anyone know how I do this from a c++ module for Godot 4?

@export var typed_test:Array[State]

When I code this in gdscript I get Typed Array in the inspector asking for the State resource (State is a custom resource created in my module)

This is what I have so far in my c++ module

TypedArray<State> states = TypedArray<State>();

in the .cpp:

void WorldStateManager::set_states(TypedArray<State> p_states) {
	states = p_states;

TypedArray<State> WorldStateManager::get_states() const {
	return states;


ClassDB::bind_method(D_METHOD("set_states", "states"), &WorldStateManager::set_states);
ClassDB::bind_method("get_states", &WorldStateManager::get_states);

ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "states", PROPERTY_HINT_ARRAY_TYPE, "State"), "set_states", "get_states");

But in the inspector I get a normal Array and it doesn’t ask for the State resource.

:bust_in_silhouette: Reply From: hidemat

Oh found my answer by looking at how it’s done in core/input/shortcut.cpp
The correct ADD_PROPERTY is as follows:

ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "states", PROPERTY_HINT_ARRAY_TYPE, vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "State")), "set_states", "get_states");

And instead of TypedArray it’s just Array

Thank you for posting answer.

YanDaik | 2023-04-24 11:16

I’m sorry I bump this topic, but do you know how to bind a non-resource typed array?