ocsigen / ts2ocaml

Generate OCaml bindings from TypeScript definitions via the TypeScript compiler API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add an option to generate `int` for `number` types

tmattio opened this issue · comments

Looking at most of the generated bindings, it seems like a better default.

In particular, all of the accessors are generated with float at the moment, which does not make sense. I also think going from int to float when users realize that the function actually supports floats is a better path than float -> int

I'm not a fan of making everything int since everything is actually float in the JS world.

Maybe we can create an abstract type that can easily be casted to/from both int and float instead.

Maybe we can create an abstract type that can easily be casted to/from both int and float instead.

Not a huge fan of adding abstractions tbh, I like that the generated bindings are using OCaml primitives.

This could be an option as well? I figure it depends on the library to bind, for instance in the case of node, number almost always means int. So the users could decide for themselves when generating bindings.

Yes, I think we can definitely add an option to emit int for number.

I added an option --int to do this 🙂