fix: parse struct references for type generation (#2552)

* fix: parse struct references for type generation

* chore: update changelog for typescript generation fix
This commit is contained in:
Dominic Lee
2023-04-26 23:23:39 +10:00
committed by GitHub
parent 0bf41090b0
commit d249c2207b
3 changed files with 27 additions and 4 deletions
@@ -11,6 +11,7 @@ import (
const expectedPromiseBindings = `// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
import {binding_test} from '../models';
export function ErrorReturn(arg1:number):Promise<void>;
@@ -18,16 +19,37 @@ export function NoReturn(arg1:string):Promise<void>;
export function SingleReturn(arg1:any):Promise<number>;
export function SingleReturnStruct(arg1:any):Promise<binding_test.PromisesTestReturnStruct>;
export function SingleReturnStructPointer(arg1:any):Promise<binding_test.PromisesTestReturnStruct>;
export function SingleReturnStructPointerSlice(arg1:any):Promise<Array<binding_test.PromisesTestReturnStruct>>;
export function SingleReturnStructSlice(arg1:any):Promise<Array<binding_test.PromisesTestReturnStruct>>;
export function SingleReturnWithError(arg1:number):Promise<string>;
export function TwoReturn(arg1:any):Promise<string|number>;
`
type PromisesTest struct{}
type PromisesTestReturnStruct struct{}
func (h *PromisesTest) NoReturn(_ string) {}
func (h *PromisesTest) ErrorReturn(_ int) error { return nil }
func (h *PromisesTest) SingleReturn(_ interface{}) int { return 0 }
func (h *PromisesTest) NoReturn(_ string) {}
func (h *PromisesTest) ErrorReturn(_ int) error { return nil }
func (h *PromisesTest) SingleReturn(_ interface{}) int { return 0 }
func (h *PromisesTest) SingleReturnStructPointer(_ interface{}) *PromisesTestReturnStruct {
return &PromisesTestReturnStruct{}
}
func (h *PromisesTest) SingleReturnStruct(_ interface{}) PromisesTestReturnStruct {
return PromisesTestReturnStruct{}
}
func (h *PromisesTest) SingleReturnStructSlice(_ interface{}) []PromisesTestReturnStruct {
return []PromisesTestReturnStruct{}
}
func (h *PromisesTest) SingleReturnStructPointerSlice(_ interface{}) []*PromisesTestReturnStruct {
return []*PromisesTestReturnStruct{}
}
func (h *PromisesTest) SingleReturnWithError(_ int) (string, error) { return "", nil }
func (h *PromisesTest) TwoReturn(_ interface{}) (string, int) { return "", 0 }
+1 -1
View File
@@ -23,7 +23,7 @@ var valuePackageIndex int
var valueTypeIndex int
func init() {
mapRegex = regexp.MustCompile(`(?:map\[(?:(?P<keyPackage>\w+)\.)?(?P<keyType>\w+)])?(?P<valueArray>\[])?(?:(?P<valuePackage>\w+)\.)?(?P<valueType>.+)`)
mapRegex = regexp.MustCompile(`(?:map\[(?:(?P<keyPackage>\w+)\.)?(?P<keyType>\w+)])?(?P<valueArray>\[])?(?:\*?(?P<valuePackage>\w+)\.)?(?P<valueType>.+)`)
keyPackageIndex = mapRegex.SubexpIndex("keyPackage")
keyTypeIndex = mapRegex.SubexpIndex("keyType")
valueArrayIndex = mapRegex.SubexpIndex("valueArray")
+1
View File
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `runtime.MenuUpdateApplicationMenu` on macOS. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2588)
- Fixed add package name for `libwebkit`/`pkg-config` and use shell.RunCommandWithENV instead of shell.RunCommand in `zypper.go`. Fixed by @wgjtyu in [PR](https://github.com/wailsapp/wails/pull/2593)
- Make sure to start the CommonFileDialogs on Windows on the Main-Thread. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2606)
- Fixed generated typescript bindings. Fixed by @dominictwlee in [PR](https://github.com/wailsapp/wails/pull/2552)
## v2.4.1 - 2023-03-20