5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 11:40:56 +08:00

Bindingings for empty go structs (#3489)

This commit is contained in:
Gjergji Ramku 2024-05-17 23:39:27 +02:00 committed by GitHub
parent a7a4341f79
commit 2f5398664f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 38 additions and 5 deletions

View File

@ -0,0 +1,34 @@
package binding_test
type WithoutFields struct {
}
func (s WithoutFields) Get() WithoutFields {
return s
}
var WithoutFieldsTest = 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);
}
}
}`,
}

View File

@ -47,8 +47,9 @@ func TestBindings_GenerateModels(t *testing.T) {
AnonymousSubStructTest, AnonymousSubStructTest,
AnonymousSubStructMultiLevelTest, AnonymousSubStructMultiLevelTest,
GeneratedJsEntityWithNestedStructTest, GeneratedJsEntityWithNestedStructTest,
EntityWithDiffNamespaces, EntityWithDiffNamespacesTest,
SpecialCharacterFieldTest, SpecialCharacterFieldTest,
WithoutFieldsTest,
} }
testLogger := &logger.Logger{} testLogger := &logger.Logger{}

View File

@ -140,7 +140,7 @@ type ChildPackageEntity struct {
ImportedPackage binding_test_import.AWrapper `json:"importedPackage"` ImportedPackage binding_test_import.AWrapper `json:"importedPackage"`
} }
var EntityWithDiffNamespaces = BindingTest{ var EntityWithDiffNamespacesTest = BindingTest{
name: "EntityWithDiffNamespaces ", name: "EntityWithDiffNamespaces ",
structs: []interface{}{ structs: []interface{}{
&ParentPackageEntity{}, &ParentPackageEntity{},

View File

@ -586,9 +586,6 @@ func (t *TypeScriptify) convertType(depth int, typeOf reflect.Type, customCode m
return "", nil return "", nil
} }
fields := t.deepFields(typeOf) fields := t.deepFields(typeOf)
if len(fields) == 0 {
return "", nil
}
t.logf(depth, "Converting type %s", typeOf.String()) t.logf(depth, "Converting type %s", typeOf.String())
if differentNamespaces(t.Namespace, typeOf) { if differentNamespaces(t.Namespace, typeOf) {
return "", nil return "", nil

View File

@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Added support for proxying assets requests to an external server. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/3463) - Added support for proxying assets requests to an external server. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/3463)
- Added support generating bindings for structs without fields. Added by [gjergj](https://github.com/Gjergj) in [PR](https://github.com/wailsapp/wails/pull/3489)
### Fixed ### Fixed
- Fixed an issue with missing icon for Windows. Fixed by [@APshenkin](https://github.com/wailsapp/wails/pull/3400) - Fixed an issue with missing icon for Windows. Fixed by [@APshenkin](https://github.com/wailsapp/wails/pull/3400)