COMMUNITY

Define typedef field named 'class'


(Remco Huijser) #1

I want to use this for defining html element types (part of a virtual dom solution) but as class is a reserved word I am not able to do this:

typedef Attributes =
{
    id: String,
    style: String,
    class: String
}

The name is perfectly valid in JavaScript (as far as I am aware of): so is there a way to trick the compiler into accepting this?


(Rudy Ges) #2

Not really =/ (well there’s always some tricks with abstracts or @:structInit interfaces, but they’re far from perfect)

See https://github.com/HaxeFoundation/haxe/issues/5105 and https://github.com/HaxeFoundation/haxe/pull/2185


(Remco Huijser) #3

Thanks for the quick reply: I think we will work around the problem for now :slight_smile: