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

Collectors.joining is missing from bundle.d.ts but present in bundle.js #66

Open
dsyer opened this issue Mar 17, 2022 · 0 comments
Open

Comments

@dsyer
Copy link
Contributor

dsyer commented Mar 17, 2022

JavaScript knows about Collectors.joining():

               Collectors.joining = function (delimiter, prefix, suffix) {
                    if (((delimiter != null && (delimiter.constructor != null && delimiter.constructor[
...
}
                    else
                        throw new Error('invalid overload');
                };

however it does not appear in the types bundle:

declare namespace java.util.stream {
    class Collectors {
        static throwingMerger<T>(): (p1: T, p2: T) => T;
        static toList<T>(): java.util.stream.Collector<T, any, java.util.List<T>>;
        static toSet<T>(): java.util.stream.Collector<T, any, java.util.Set<T>>;
        static toMap$java_util_function_Function$java_util_function_Function<T, K, U>(keyMapper: (p1: any) => any, valueMapper: (p1: any) => any): java.util.stream.Collector<T, any, java.util.Map<K, U>>;
        static toMap$java_util_function_Function$java_util_function_Function$java_util_function_BinaryOperator<T, K, U>(keyMapper: (p1: any) => any, valueMapper: (p1: any) => any, mergeFunction: (p1: U, p2: U) => U): java.util.stream.Collector<T, any, java.util.Map<K, U>>;
        static toMap$java_util_function_Function$java_util_function_Function$java_util_function_BinaryOperator$java_util_function_Supplier<T, K, U, M extends java.util.Map<K, U>>(keyMapper: (p1: any) => any, valueMapper: (p1: any) => any, mergeFunction: (p1: U, p2: U) => U, mapSupplier: () => M): java.util.stream.Collector<T, any, M>;
        static toMap<T, K, U, M extends java.util.Map<K, U> = any>(keyMapper?: any, valueMapper?: any, mergeFunction?: any, mapSupplier?: any): any;
        static mapMerger<K, V, M extends java.util.Map<K, V> = any>(mergeFunction: (p1: V, p2: V) => V): (p1: M, p2: M) => M;
    }
...
}

and consequently if you try to transpile code that uses Collectors.join() e.g.

public class Sweet {

	private static List<String> values = Arrays.asList("Hello", "World");
	
	public String hello() {
		return values.stream().collect(Collectors.joining(" "));
	}
}

then the transpiler barfs at build time:

[ERROR] transpilation failed
org.apache.maven.plugin.MojoFailureException: transpilation failed with 1 error(s) and 0 warning(s)

=========================================
TRANSPILATION ERRORS SUMMARY:
* /home/dsyer/dev/scratch/jsweet-demo/src/main/java/com/example/demo/Sweet.java(12,67)[ts] Property 'joining' does not exist on type 'typeof Collectors'.


=========================================
    at org.jsweet.AbstractJSweetMojo.transpile (AbstractJSweetMojo.java:701)
    at org.jsweet.JSweetMojo.execute (JSweetMojo.java:43)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant