benmerckx / genes

Generates split ES6 modules and Typescript definitions from Haxe modules.
43 stars 8 forks source link

Interfaces are exported in a strange way? #76

Open vantreeseba opened 1 month ago

vantreeseba commented 1 month ago

IModule2D.hx

package dropecho.noise;

import dropecho.utils.FastMath;

interface IModule2D {
    public function value(x:F32, y:F32):F32;
}

IModule2d.d.ts

import {F32} from "../utils/FastMath"

export declare interface IModule2D {
    value(x: F32, y: F32): F32
}

IModule2d.js

import {Register} from "../../genes/Register.js"

const $global = Register.$global

export const IModule2D = function() {};
IModule2D.__isInterface__ = true;

index.js

export {IModule2D} from "./dropecho/noise/IModule2D.js"

This causes the export to think it's exporting a type (though this is fine in JS since it ignores those anyway).

benmerckx commented 1 month ago

Outside of Haxe the exported value is mostly useless and the properties it has might change with Haxe versions.

I guess I could adjust it to:

export const IModule2D: {__isInterface__: true}
export interface IModule2D {
  value(x: F32, y: F32): F32
}

Would that be closer to what you'd expect?