DEV Community

loading...

Discussion on: Inlined values in BuckleScript

Collapse
sukantpal profile image
Sukant Pal • Edited

Thanks for this article! I am using this technique to binding enumerations in the @pixi/constants package (here: github.com/pixijs/pixi.js/blob/dev...).

module TYPES: {
    type t = pri int;

    let half_float: t;
} = {
    type t = int;

    let half_float = 36193;
}

instead of

module TYPES = {
  [@bs.scope "TYPES"] [@bs.module "@pixi/constants"]
  external half_float = 36193;
}

Do you think this would be the correct approach?

Collapse
yawaramin profile image
Yawar Amin Author

Hi, no problem. Yes the first code sample looks correct to me. If you add the [@bs.inline] attribute in the correct places as explained in the post, the compiler will generate constant literals at the right places.