elsassph / hxtsdgen

TypeScript declaration file generator for Haxe JavaScript output target
65 stars 12 forks source link

Typedef generation #12

Closed elsassph closed 5 years ago

elsassph commented 5 years ago

Typedef anonymous structure can now be exposed, and will be refered to instead of the anonymous structure.

Also fixes incomplete handling of named exports.

@:expose("X2") 
typedef X = {
   x:Int;
}

@:expose
interface A {
   var field:X;
}

Produces:

export type X2 = {
   x: number;
}

export interface A {
   field: X2;
}
nadako commented 5 years ago

Maybe we should generate TS interface for typedefs to anon structure.

elsassph commented 5 years ago

@nadako I agree that's a possibility - it will technically work to use an interface but on the Haxe side it's an anonynous type and so it is here in TypeScript. Should that be an option maybe?