hxtsdgen icon indicating copy to clipboard operation
hxtsdgen copied to clipboard

@:optional was not gen of typedef

Open sonygod opened this issue 4 years ago • 2 comments

@:expose
typedef GameType ={

  var id:Int;
    var ?name:String;
} 

will gen

export type GameType = {
	id: number;
	name: string;
}

should be

export type GameType = {
	id: number;
	name?: string;
}

sonygod avatar Nov 09 '20 03:11 sonygod

I think your syntax isn't entirely correct (though it may be accepted by the compiler).

For a typedef with var prop: Type it should be:

@:expose
typedef GameType ={
   var id:Int;
   @:optional var name:String;
}

elsassph avatar Nov 09 '20 07:11 elsassph

emm,this is got the same result as var ?name:String ==@:optional var name:String;

sonygod avatar Nov 09 '20 08:11 sonygod