mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 03:51:18 +08:00
Bindingings for empty go structs (#3489)
This commit is contained in:
parent
a7a4341f79
commit
2f5398664f
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}`,
|
||||
}
|
@ -47,8 +47,9 @@ func TestBindings_GenerateModels(t *testing.T) {
|
||||
AnonymousSubStructTest,
|
||||
AnonymousSubStructMultiLevelTest,
|
||||
GeneratedJsEntityWithNestedStructTest,
|
||||
EntityWithDiffNamespaces,
|
||||
EntityWithDiffNamespacesTest,
|
||||
SpecialCharacterFieldTest,
|
||||
WithoutFieldsTest,
|
||||
}
|
||||
|
||||
testLogger := &logger.Logger{}
|
||||
|
@ -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{},
|
||||
|
@ -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
|
||||
|
@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### 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 generating bindings for structs without fields. Added by [gjergj](https://github.com/Gjergj) in [PR](https://github.com/wailsapp/wails/pull/3489)
|
||||
|
||||
### Fixed
|
||||
- Fixed an issue with missing icon for Windows. Fixed by [@APshenkin](https://github.com/wailsapp/wails/pull/3400)
|
||||
|
Loading…
Reference in New Issue
Block a user