Haxe compiler metadata can be really handy to get specific behavior or to tweak the language based on your needs.

You can get the full list of supported compiler flags by running haxe --help-metas.

It’s a big list and the following are some of my favourites.

@:overload - I use this a lot when writing externs where you can overload fucntion paramater declarations and return type. The first one that is matched will be used.

@:overload(function(shape:Rectangle):GraphicsData {})
@:overload(function(shape:Ellipse):GraphicsData {})
@:overload(function(shape:Polygon):GraphicsData {})
function drawShape(shape:Circle):GraphicsData;

@:final - When you want to mark the class as final.

class MyClass {}

If you try to extend MyClass you will get compile time error Cannot extend a final class.

@:optional - When you want to declare optional fields in typedef.

typedef TextField = {
	var text:String;
	@:optional var font:String;

@:publicFields - When you want to change the default visibility of the whole class and it’s sub classes from private to public. I find this useful for static classes.

class MyClass {
	static inline var width:Float = 1024;
	static inline var height:Float = 768;
	static inline var ratio:Float = 1;

@:keep - Unused variables and functions will be removed with dead code elimination -dce full. You can force to keep them using this metadata.

@:keep public function getChildByName(name:String):DisplayObject {
	return _container.getChildByName(name);

All of the above are generic metadata and can be used across platforms and there are many more generic and platform specific metadata you may find useful for your specific needs so explore and please post in the comments section if you find anything interesting.

Update (14 Jan 2015): Another JavaScript specific metadata which I find useful is @:expose. It can be used on any class to make it available/accessible from the window object. This is useful when you want to expose any of your haxe classes to another library via window object.