mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 20:40:33 +08:00
import models on binding definition (#1231)
This commit is contained in:
parent
c5c0617c89
commit
9097c9086b
@ -129,6 +129,7 @@ func (b *Bindings) GenerateBackendTS(targetfile string) error {
|
|||||||
store := b.db.store
|
store := b.db.store
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
|
|
||||||
|
output.WriteString("import * as models from './models';\n\n")
|
||||||
output.WriteString("export interface go {\n")
|
output.WriteString("export interface go {\n")
|
||||||
|
|
||||||
var sortedPackageNames slicer.StringSlicer
|
var sortedPackageNames slicer.StringSlicer
|
||||||
@ -221,7 +222,7 @@ func goTypeToJSDocType(input string) string {
|
|||||||
return "Array<" + arrayType + ">"
|
return "Array<" + arrayType + ">"
|
||||||
default:
|
default:
|
||||||
if strings.ContainsRune(input, '.') {
|
if strings.ContainsRune(input, '.') {
|
||||||
return strings.Split(input, ".")[1]
|
return "models." + strings.Split(input, ".")[1]
|
||||||
}
|
}
|
||||||
return "any"
|
return "any"
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,11 @@ func Test_goTypeToJSDocType(t *testing.T) {
|
|||||||
input: "foo",
|
input: "foo",
|
||||||
want: "any",
|
want: "any",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "types",
|
||||||
|
input: "main.SomeType",
|
||||||
|
want: "models.SomeType",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user