jrouwe / JoltPhysics.js

Port of JoltPhysics to JavaScript using emscripten
MIT License
270 stars 21 forks source link

chore: bump webidl-dts-gen from 1.0.2 to 1.1.1 #6

Closed isaac-mason closed 1 year ago

isaac-mason commented 1 year ago

Previously, the generated typescript type for an enum was a union of the member name strings. This is the desired behaviour for the webidl spec, but does not match the bindings that emscripten generates.

For example, looking at the Layers enum:

enum class Layers
{
    NON_MOVING = 0,
    MOVING = 1,
    NUM_LAYERS = 2
};

With the following webidl:

enum Layers {
    "Layers::MOVING",
    "Layers::NON_MOVING"
};

This typescript type was generated:

type Layers = "Layers::MOVING" | "Layers::NON_MOVING";

There's a few issues with this with regards to emscripten-generated bindings:

With webidl-dts-gen v1.1.1, the output for enums in emscripten mode is now:

const MOVING: any;
const NON_MOVING: any;
type Layers = typeof MOVING | typeof NON_MOVING;
function _emscripten_enum_Layers_MOVING(): Layers;
function _emscripten_enum_Layers_NON_MOVING(): Layers;
jrouwe commented 1 year ago

Thanks!

B.t.w. I tried to publish a new version with this change, but I see v0.0.3 still has the old enum definitions.

I ran build.sh and then npm publish.

Is there something else I should do?

isaac-mason commented 1 year ago

No worries :)

You might just need to do another npm install?

jrouwe commented 1 year ago

That fixes it, thanks!