GJS Legacy Class Syntax

Prior to the introduction of ES6 classes in GJS 1.50, GJS had its own implementation of classes and interfaces to interact with classes. This was implemented in the imports.lang module via imports.lang.Class and imports.lang.Interface.

const Lang = imports.lang;

var A = new Lang.Class({
    Name: 'A',
    GTypeName: 'A',
    Signals: {},
    InternalChildren: [],
    Children: [],
    Extends: GObject.Object,
    _init(a, b) {
      this.parent(a, b);
    }
});

Comparison between legacy and ES6 implementations

LegacyES6
var A = new Lang.Class({
   GTypeName: 'A',
   Name: 'A',
   Extends: GObject.Object,
   _init(a, b) {
       this.parent(a);
       this.b = b;
   }
 });
 
var A = GObject.registerClass({
       GTypeName: 'A',
   }, class A /* ... */
      /* ... */ extends GObject.Object { 
          _init(a, b) {
             super._init(a);
             this.b = b;
         }
   }
);