UNPKG

@ts-for-gir/lib

Version:

Typescript .d.ts generator from GIR for gjs

21 lines (16 loc) 711 B
import type { IntrospectedInterface } from "../gir/introspected-classes.ts"; import { GirVisitor } from "../visitor.ts"; export class InterfaceVisitor extends GirVisitor { visitInterface = (node: IntrospectedInterface): IntrospectedInterface => { // If an interface does not list a prerequisite type, we fill it with GObject.Object if (!node.noParent && node.superType == null) { const gobject = node.namespace.assertInstalledImport("GObject"); const GObject = gobject.assertClass("Object"); if (!GObject) { throw new Error(`GObject.Object could not be found while generating ${node.namespace.namespace}.${node.name}`); } node.superType = GObject.getType(); } return node; }; }