You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I waste a lot of time hunting down bugs that result from type errors that I make when I write calls in the JavaScript part of my program of values exported from the OCaml part of my program using Js.export or Js.export_all.
Describe the solution you'd like
It would be great if I could use TypeScript to catch those errors as I type. TypeScript needs to know the TypeScript type of the exported values; it would be great if js_of_ocaml would generate a TypeScript declaration file for exported values automatically.
Describe alternatives you've considered
Alternatives include:
translating the JavaScript code into OCaml and letting the OCaml typechecker do the work. But: that can be a lot of work, and code that interacts heavily with the DOM is often written more elegantly in JavaScript.
Writing the TypeScript declaration file manually. But: that's quite a bit of work, too, and error-prone, and it will get out of date as I work on the OCaml code.
The text was updated successfully, but these errors were encountered:
For example, suppose I have the following code in mycode.ml:
openJs_of_ocamllet()=Js.export_all beginobject%js
val myJsBool =Js.booltrue
val myNumber =10
val myJsString =Js.string"Hello"
val myOCamlBool =true
val myOCamlString ="Hello"
val myOCamlIntList = [1;2;3]
method myMethod x = x +1end
end
So, for each OCaml type, a type definition should be generated that binds a unique type name derived from the OCaml type to an object type that is chosen to be highly unlikely to be compatible with any other type that appears in the user's TypeScript program.
btj
changed the title
[FEATURE REQUEST] Generate TypeScript declaration file for values exported using Js.export_all
[FEATURE REQUEST] Generate TypeScript declaration file for values exported using Js.export/export_all
Mar 3, 2022
Is your feature request related to a problem? Please describe.
I waste a lot of time hunting down bugs that result from type errors that I make when I write calls in the JavaScript part of my program of values exported from the OCaml part of my program using
Js.export
orJs.export_all
.Describe the solution you'd like
It would be great if I could use TypeScript to catch those errors as I type. TypeScript needs to know the TypeScript type of the exported values; it would be great if js_of_ocaml would generate a TypeScript declaration file for exported values automatically.
Describe alternatives you've considered
Alternatives include:
The text was updated successfully, but these errors were encountered: