diff --git a/src/conversion/FileProcessor.ts b/src/conversion/FileProcessor.ts index 20aa5e1..d762aa0 100644 --- a/src/conversion/FileProcessor.ts +++ b/src/conversion/FileProcessor.ts @@ -383,7 +383,7 @@ export class FileProcessor { header.append("\n"); let aliases = ""; - if (this.configuration.options?.useUnqualifiedTypes) { + if (this.configuration.options?.useUnqualifiedTypes && this.configuration.javaLib !== "") { // Create const reassignments and type aliases depending on the type of the imported symbol. this.packageImports.forEach((symbol, key) => { // Cannot create a type alias for an enum type (it would be infinite recursion). @@ -722,7 +722,7 @@ export class FileProcessor { if (context.EXTENDS()) { this.getContent(localBuilder, context.EXTENDS()); this.processTypeType(localBuilder, context.typeType()); - } else { + } else if (this.configuration.javaLib !== "") { // Add the default extends clause. localBuilder.append(" extends JavaObject"); this.registerJavaImport("JavaObject"); @@ -1355,6 +1355,11 @@ export class FileProcessor { } } + if (!hasSuperCall && this.configuration.javaLib === "") { + // Don't add a super call if no base class is specified and no java lib is used. + hasSuperCall = true; + } + result.containsThisCall = hasThisCall; // See if we should automatically add a call to super. Only if none exists yet and this class extends another. @@ -2739,8 +2744,12 @@ export class FileProcessor { builder.append("class extends "); } else { if (info.symbol instanceof InterfaceSymbol) { - builder.append("class extends JavaObject implements "); - this.registerJavaImport("JavaObject"); + if (this.configuration.javaLib === "") { + builder.append("class implements "); + } else { + builder.append("class extends JavaObject implements "); + this.registerJavaImport("JavaObject"); + } } else { builder.append("class extends "); } diff --git a/src/conversion/JavaToTypeScript.ts b/src/conversion/JavaToTypeScript.ts index c3ef8ce..07b09a9 100644 --- a/src/conversion/JavaToTypeScript.ts +++ b/src/conversion/JavaToTypeScript.ts @@ -201,7 +201,7 @@ export interface IConverterConfiguration { export class JavaToTypescriptConverter { public constructor(private configuration: IConverterConfiguration) { let javaLib; - if (!configuration.javaLib) { + if (configuration.javaLib === undefined) { javaLib = "jree"; // Use the jree node module as default. } else if (configuration.javaLib.indexOf("/") < 0) { javaLib = configuration.javaLib; // Assume this is another node module.