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

Nullable fields that hold JsFunctions have wrong generated types #109

Open
niloc132 opened this issue Nov 27, 2024 · 0 comments
Open

Nullable fields that hold JsFunctions have wrong generated types #109

niloc132 opened this issue Nov 27, 2024 · 0 comments

Comments

@niloc132
Copy link
Member

Java input:

@JsFunction
public interface TransportFactory {
  Transport create(Options options);
}
@JsNullable
public TransportFactory transportFactory

Resulting field:

transportFactory?:(options:Options)=>Transport|null;

The type of that field is incorrect - as written it says that the function might return null, instead of saying that the field is allowed to be null. Correct options could be

Put the null first:

transportFactory?:null|(options:Options)=>Transport;

Add parens around functions if they are going to be unioned

transportFactory?:((options:Options)=>Transport)|null;
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