Type errors on gjs dbus API

Hello, I’m working on an extension (the code is here if necessary), and I’mgetting a weird error from the language server.

Basically, I have an exported dbus object, and I emit the property change with:

this.exportedObject?.emit_property_changed(
                'Status',
                GLib.Variant.new_uint32(this.status));

But the IDE marks this as an error with this message: Argument of type 'Variant<"u">' is not assignable to parameter of type 'Variant<any>'. The types returned by 'byteswap().get_data_as_bytes()' are incompatible between these types. Type 'Bytes' is missing the following properties from type 'Bytes': _init, new_from_bytes.

How do I fix this? They should both be the same type (GLib.Variant<_>), and Variant<"u"> more specialized than Variant<any>.

Hi,

I’m not using gjs, so cannot help you directly, but using GLib via C or Python, I found that the value needs to be packaged in a tuple. So likely the following will work in your case as well:

GLib.Variant.new_tuple(GLib.Variant.new_uint32(this.status))