mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 10:23:03 +08:00
Fixed generated typescript type for []byte. (#701)
This commit is contained in:
parent
6b919808c9
commit
0966c96ef0
@ -144,6 +144,8 @@ func goTypeToJSDocType(input string) string {
|
|||||||
return "number"
|
return "number"
|
||||||
case input == "bool":
|
case input == "bool":
|
||||||
return "boolean"
|
return "boolean"
|
||||||
|
case input == "[]byte":
|
||||||
|
return "string"
|
||||||
case strings.HasPrefix(input, "[]"):
|
case strings.HasPrefix(input, "[]"):
|
||||||
arrayType := goTypeToJSDocType(input[2:])
|
arrayType := goTypeToJSDocType(input[2:])
|
||||||
return "Array.<" + arrayType + ">"
|
return "Array.<" + arrayType + ">"
|
||||||
|
87
v2/internal/binding/generate_test.go
Normal file
87
v2/internal/binding/generate_test.go
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package binding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_goTypeToJSDocType(t *testing.T) {
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "string",
|
||||||
|
input: "string",
|
||||||
|
want: "string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "error",
|
||||||
|
input: "error",
|
||||||
|
want: "Error",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "int",
|
||||||
|
input: "int",
|
||||||
|
want: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "int32",
|
||||||
|
input: "int32",
|
||||||
|
want: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uint",
|
||||||
|
input: "uint",
|
||||||
|
want: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "uint32",
|
||||||
|
input: "uint32",
|
||||||
|
want: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "float32",
|
||||||
|
input: "float32",
|
||||||
|
want: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "float64",
|
||||||
|
input: "float64",
|
||||||
|
want: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bool",
|
||||||
|
input: "bool",
|
||||||
|
want: "boolean",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "[]byte",
|
||||||
|
input: "[]byte",
|
||||||
|
want: "string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "[]int",
|
||||||
|
input: "[]int",
|
||||||
|
want: "Array.<number>",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "[]bool",
|
||||||
|
input: "[]bool",
|
||||||
|
want: "Array.<boolean>",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "anything else",
|
||||||
|
input: "foo",
|
||||||
|
want: "any",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := goTypeToJSDocType(tt.input); got != tt.want {
|
||||||
|
t.Errorf("goTypeToJSDocType() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user