Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java package name components that are JavaScript reserved words cause failures #53

Open
JessHolle opened this issue Jun 29, 2023 · 3 comments

Comments

@JessHolle
Copy link

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.

@bsorrentino
Copy link
Owner

bsorrentino commented Jun 23, 2024

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 ?

@JessHolle
Copy link
Author

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.

@JessHolle
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants