We are pleased to announce that JSweet 2 is now available.
JSweet 2 is the outcome of several months of intense work with several partners that have been using JSweet for different purposes. It brings to you major improvements in the way you can transpile your Java code to JavaScript. Here are the main changes:
def
package. With the candy generator tool, you can translate the TypeScript definitions and get a first Java version, which you can modify for your own purpose, and share with the community in the jsweet-candies organization.java.io
, java.lang.reflect
, or java.math
, is now built-in or easy to plug in with the extension API.For the sake illustrating new JSweet v2 brand new power, let us say your Java program uses java.util.Date
objects. By default, JSweet translates java.util.Date
objects to JavaScript dates. However, for your context (and some personal reasons), you may want to translate dates to strings. With JSweet 2, you can simply use the extension API to write an adapter that will map the java.util.Date
type to the TypeScript string
type. It is as simple as this (see the complete example here):
public class HelloWorldAdapter extends org.jsweet.transpiler.extension.PrinterAdapter { public HelloWorldAdapter(PrinterAdapter parent) { super(parent); addTypeMapping(java.util.Date.class.getName(), "string"); } }
For more details and secondary features, please read the release notes.
We hope to keep in touch with you soon and plan to post some real-world success stories about using JSweet. Don’t hesitate to contact us in the meantime if you have any questions.