-
Notifications
You must be signed in to change notification settings - Fork 23
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
@record
types with no members have no create() method
#51
Comments
Test demonstrating the issue master...Vertispan:jsinterop-generator:empty-record-type-factory-method |
Hmm |
Does it matter if the parent has fields or not? Even if a record with no supertype has no fields, if the user must create an instance to use some api, it makes more sense to call |
My recollection is; when we emit create methods unconditionally it had some unintended effect (though I don't remember what it was). |
Steps to reproduce, create a record type with no members.
Expected, a Java interface with a static
create()
method. Actual output is a Java interface with no contents.--
While this might seem like a weird edge case, there are at least two ways that this comes up. First, when tsickle generates externs from typescript where a type is re-exported in another file, tsickle will generate a new type that extends the existing type. Second, a record type that extends from two other record types, but doesn't contribute new fields.
Expected Java output,
Actual Java output
An easy workaround is to just create an instance of a supertype, or just a plain
JsObject.create(null)
orJsPropertyMap.of()
, then wrap in a cast as the usual implementation does. But this isn't expected to be the correct way, since all other records get a generated factory method.The text was updated successfully, but these errors were encountered: