Skip to content

Nullable fields that hold JsFunctions have wrong generated types #109

@niloc132

Description

@niloc132

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions