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

Feature Request: Add Support for Generating TypeScript Method Signatures from Java Class Methods #1069

Open
Mcayear opened this issue Sep 16, 2024 · 0 comments

Comments

@Mcayear
Copy link

Mcayear commented Sep 16, 2024

Description:

Hi, and thanks for developing and maintaining typescript-generator! It's been an incredibly useful tool for generating TypeScript definition files from Java classes, especially for use cases involving JSON object mapping and static type checking in TypeScript.

However, I’ve noticed that currently, typescript-generator focuses primarily on generating TypeScript interfaces based on the fields (properties) of Java classes, but it doesn't generate TypeScript method signatures for the methods defined in these Java classes.

For example, given the following Java class:

public class Person {
    public String name;
    public int age;

    public String greet() {
        return "Hello, " + name;
    }
}

The output TypeScript interface would be:

interface Person {
    name: string;
    age: number;
}

Requested Feature:

I would like to request that typescript-generator be extended to also generate method signatures in the TypeScript definition files. Using the example above, the desired output would include the method signature as follows:

interface Person {
    name: string;
    age: number;

    greet(): string;
}

Why This Feature is Important:

  • Completeness: Many Java classes contain methods that perform important operations, and these methods are often integral to the class's functionality. Including method signatures in the generated TypeScript interfaces would provide a more complete representation of the Java class, reducing the need to manually extend the generated .d.ts files.

  • Consistency with Class Usage: In many TypeScript projects, it’s common to need both the data structure (fields) and the functionality (methods) provided by a Java class. Including methods would allow developers to fully type-check their TypeScript code that interacts with these Java classes.

Thank you for considering this request! This feature would greatly improve the usability of typescript-generator for projects that rely on Java methods in addition to fields.

Looking forward to your feedback and insights!

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