jsweet icon indicating copy to clipboard operation
jsweet copied to clipboard

Java `final` modifier should transpile to TS `const` or `readonly`

Open thw0rted opened this issue 6 years ago • 2 comments

If I have a Java class like

public class Test {
  public static final int one = 1;
}

JSweet will turn this into

class Test {
  public static one: number = 1;
}

I expect Test.one = 2 to fail, obviously. In the original Java, it does, but in the generated TS it does not.

ETA: to be clear, I'd like to see the generated class come out as

class Test {
  public static readonly one: number = 1;
}

thw0rted avatar Jun 14 '18 10:06 thw0rted

+1 Readonly modifier did not exist at the beginning but now we could do so. Do you want to contribute? It is an easy one

lgrignon avatar Jun 14 '18 11:06 lgrignon

I was afraid you'd say that... is this the same reason why private transpiles to /* private */ instead of actually using the private keyword? Same as last time, if I have some free time to figure out the internals enough to make the change myself, I'll let you know. Thanks!

thw0rted avatar Jun 14 '18 11:06 thw0rted