cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 159 forks source link

Property 'doubleToRawLongBits' does not exist on type 'typeof DoubleHelper'. #679

Open jkhuangg opened 3 years ago

jkhuangg commented 3 years ago

I am trying to transpile these lines of Java into JS:

double[] data = {//an array of doubles};

Long hash = 0;
    if( data != null )
      for( double d : data ) hash ^= Double.doubleToRawLongBits(d) >> 6; 

But I am getting this error: [ERROR] Failed to execute goal org.jsweet:jsweet-maven-plugin:3.0.0:jsweet (generate-js) on project jsweet-quickstart: transpilation failed: transpilation failed with 1 error(s) and 0 warning(s) [ERROR] [ERROR] ========================================= [ERROR] TRANSPILATION ERRORS SUMMARY: [ERROR] * /mnt/c/Users/Yiju Huang/Documents/karandeep/evpt/src/main/java/DRF_model_python_1613267082863_1.java(33,65)[ts] Property 'doubleToRawLongBits' does not exist on type 'typeof DoubleHelper'. [ERROR] [ERROR] [ERROR] =========================================

I used the Jsweet sandbox to transpile doubleToRawLongBits to JS/TS and it was OK. Not sure what is wrong here.

lgrignon commented 3 years ago

@jkhuangg it's a J4TS bug

You can easily add the requested API in this J4TS implementation: https://github.com/j4ts/j4ts/blob/master/src/main/java/javaemul/internal/DoubleHelper.java

If you file a PR I will review/merge it quickly