Generating invalid `@js` (gen_js_api) expression
joelburget opened this issue · comments
I used this example (test.d.ts
):
export interface CSSDataV1 {
version: 1 | 1.1;
}
❯ ts2ocaml jsoo --preset=minimal --output-dir test-output test.d.ts
❯ ocamlfind gen_js_api/gen_js_api test-output/test.d.ts.mli
File "test-output/test.d.ts.mli", line 13, characters 50-64:
13 | val get_version: t -> ([`L_n_1[@js 1] | `L_n_1_1[@js 1.100000]] [@js.enum]) [@@js.get "version"]
^^^^^^^^^^^^^^
Error: Invalid expression
Changing 1.100000
to 2
works but floats all fail.
I'm not sure whether this is a ts2ocaml
or gen_js_api
bug. https://github.com/LexiFi/gen_js_api/blob/master/TYPES.md isn't clear what values are accepted in [@js]
but only shows examples of ints and strings.
This is gen_js_api
lacking a support for float enums. I will open a PR for it.
gen_js_api
1.0.9, which adds support for float enums, is now on OPAM. You should upgrade it and you don't have to use opam pin
for gen_js_api
anymore.