This will work:
http://try.haxe.org/#74454
The basic issue is that the type of `{ name: "Sword", value: 3, dmg: 4 }` is *not* `Weapon` as you might expect, but instead it is a type I shall call `Exactly<{ name:String, value:Int, dmg:Int }>` (this is not really correct, but it should give you a workable mental model). That type is compatible with exactly one other type, i.e. `{ name:String, value:Int, dmg:Int }` (the type you aliased as `Weapon`), but none that type's supertypes, e.g. `Item`, `{ dmg: Int }`, `{ name: String }`, etc.
So what you have is this:
var items:Array<Item> = [{ name: "Sword", value: 3, dmg: 4 }];
Which is pretty much equivalent to this:
var tmp:Exactly<{ name:String, value:Int, dmg:Int }> = { name: "Sword", value: 3, dmg: 4 };
var items:Array<Item> = [tmp];
And that doesn't work, because `Exactly<Weapon>` is incompatible with `Item`. If however you put the value into an expression that has the type `Weapon` (by for example defining it as a variable), then it works:
var tmp:Exactly<{ name:String, value:Int, dmg:Int }> = { name: "Sword", value: 3, dmg: 4 };
var sword:Weapon = tmp;
var items:Array<Item> = [sword];
The reason for *why* object literals are inferred to `Exactly<{ ... }>` is that this helps avoiding a certain class of bugs, as is discussed in the issue (and probably a dozen other places).
Best,
Juraj