java2typescript
java2typescript copied to clipboard
Java package name components that are JavaScript reserved words cause failures
If one has a Java package name like "com.acme.delete" or "com.acme.export" then the resulting TypeScript will not work due to "delete" and "export" being reserved words.
Hi @JessHolle sorry for late in answer, but I missed your request.
A solution could be add a prefix like $
to the reserved words. What do you think ? you still need this fix ?
I ended up using java2typescript as an inspiration for my own custom Javadoc-doclet-based TypeScript definition generator -- and generating only a .d.ts file, i.e. no actual JavaScript implementation.
On this particular front, I ended up using xx_yy_zz namespaces for packages, rather than x.y.z namespaces to resolve the issue.
Trying to straddle Java and JavaScript's notions of some types (i.e. chars and strings) in the same way that Nashorn does was challenging and the result a bit imperfect, I believe. And some of Nashorn's special sugar for extension (extend, etc), didn't end up getting covered quite correctly, IIRC.
P.S. I only generate a .d.ts file in my case because I'm dealing with a very large Java API -- and don't want to produce large amounts of actual JavaScript due to that.