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

Default values for class constructors #1042

Open
leomayer opened this issue Nov 28, 2023 · 0 comments
Open

Default values for class constructors #1042

leomayer opened this issue Nov 28, 2023 · 0 comments

Comments

@leomayer
Copy link

As a follow up of #1041:
I create a default constructor for the output. In my inherited children I have in the Java code the following base defintion:

private List<T> children = new ArrayList<>();

but somehow the assignment is not taken over for the class constructor. I only have

constructor(data: ChapterDto<T>) {
		this.children = data.children;
}

but would prefer to have the default settings from Java take over as well. Basically the code should look like

constructor(data: ChapterDto<T>) {
		this.children = data.children ?? [] as T[];
}

or more generally speaking: is there a way

  • to set the default Java values to the Typescript objects (e.g. int will be 0, boolean will be false, ...)?
  • to take over the definitions from Java into the class constructors?
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