GObject.type_ensure

function type_ensure(type: GObject.Type): void {
    // Gjs wrapper for g_type_ensure()
}
  

Ensures that the indicated type has been registered with the type system, and its _class_init() method has been run.

In theory, simply calling the type's _get_type() method (or using the corresponding macro) is supposed take care of this. However, _get_type() methods are often marked %G_GNUC_CONST for performance reasons, even though this is technically incorrect (since %G_GNUC_CONST requires that the function not have side effects, which _get_type() methods do on the first call). As a result, if you write a bare call to a _get_type() macro, it may get optimized out by the compiler. Using GObject.type_ensure guarantees that the type's _get_type() method is called.

Since 2.34

type

a GLib.Type