Skip to content

Commit

Permalink
Bindingings for empty go structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gjergj committed May 17, 2024
1 parent d4dabc1 commit e03bf5b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package binding_test

type WithoutFields struct {
}

func (s WithoutFields) Get() WithoutFields {
return s
}

var SpecialCharacterFieldTest = BindingTest{
name: "StructWithoutFields",
structs: []interface{}{
&WithoutFields{},
},
exemptions: nil,
shouldError: false,
want: `
export namespace binding_test {
export class WithoutFields {
static createFrom(source: any = {}) {
return new WithoutFields(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
}
}
}`,
}
3 changes: 2 additions & 1 deletion v2/internal/binding/binding_test/binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func TestBindings_GenerateModels(t *testing.T) {
AnonymousSubStructTest,
AnonymousSubStructMultiLevelTest,
GeneratedJsEntityWithNestedStructTest,
EntityWithDiffNamespaces,
EntityWithDiffNamespacesTest,
SpecialCharacterFieldTest,
}

testLogger := &logger.Logger{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ type ChildPackageEntity struct {
ImportedPackage binding_test_import.AWrapper `json:"importedPackage"`
}

var EntityWithDiffNamespaces = BindingTest{
var EntityWithDiffNamespacesTest = BindingTest{
name: "EntityWithDiffNamespaces ",
structs: []interface{}{
&ParentPackageEntity{},
Expand Down
3 changes: 0 additions & 3 deletions v2/internal/typescriptify/typescriptify.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,6 @@ func (t *TypeScriptify) convertType(depth int, typeOf reflect.Type, customCode m
return "", nil
}
fields := t.deepFields(typeOf)
if len(fields) == 0 {
return "", nil
}
t.logf(depth, "Converting type %s", typeOf.String())
if differentNamespaces(t.Namespace, typeOf) {
return "", nil
Expand Down

0 comments on commit e03bf5b

Please sign in to comment.