Skip to content

Generating invalid @js (gen_js_api) expression #39

@joelburget

Description

@joelburget

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions