{%- set typename = name|escape_toplevel %}
{%- set value = typename + suffix %}

{%- if error_domain %}
interface {{ typename }} extends GLib.Error {}

interface {{ value }} {
    readonly $gtype: GObject.GType<{{ typename }}>

    new(props: { message: string, code: number }): {{ typename }}

    {%- for member in members %}
    {{ member.jsdoc|indent(4) if member.jsdoc }}
    readonly "{{ member.name }}": {{ member.value }}
    {%- endfor %}

    {%- for fn in functions %}
    {{ fn }}
    {%- endfor %}
}

interface $Exports {
    {{ jsdoc|indent(4) if jsdoc }}
    {{ name|escape_member }}: {{ value }}
}
{%- else %}
interface {{ value }} {
    readonly $gtype: GObject.GType<{{ typename }}>

    {%- for member in members %}
    {{ member.jsdoc|indent(4) }}
    readonly "{{ member.name }}": {{ member.value }}
    {%- endfor %}
}
type {{ typename }} = {% if suffix == "Enum" -%}
        {{ value }}[Exclude<keyof {{ value }}, "$gtype">]
    {%- else -%}
        number
    {%- endif %}
interface $Exports {
    {{ jsdoc|indent(4) if jsdoc }}
    {{ name|escape_member }}: {{ value }}
    {%- for fn in functions %}
    {{ fn }}
    {%- endfor %}
}
{%- endif %}
