3.2.2 Defaults

Since Haxe 4.3 it is possible to specify a default type for each type parameter of a type. When using such a type in type annotations, type parameters with a default can be omitted:

class Example<T = Int, U = Int> {
  public var a:T;
  public var b:U;
  public function new() {}
}

function main():Void {
  var x:Example = new Example();
  $type(x.a); // Int
  $type(x.b); // Int

  var y:Example<Bool> = new Example();
  $type(y.a); // Bool
  $type(y.b); // Int

  var z:Example<String, Int> = new Example();
  $type(z.a); // String
  $type(z.b); // Int
}