mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 21:10:54 +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
|
||||
var output bytes.Buffer
|
||||
|
||||
output.WriteString("import * as models from './models';\n\n")
|
||||
output.WriteString("export interface go {\n")
|
||||
|
||||
var sortedPackageNames slicer.StringSlicer
|
||||
@ -221,7 +222,7 @@ func goTypeToJSDocType(input string) string {
|
||||
return "Array<" + arrayType + ">"
|
||||
default:
|
||||
if strings.ContainsRune(input, '.') {
|
||||
return strings.Split(input, ".")[1]
|
||||
return "models." + strings.Split(input, ".")[1]
|
||||
}
|
||||
return "any"
|
||||
}
|
||||
|
@ -81,6 +81,11 @@ func Test_goTypeToJSDocType(t *testing.T) {
|
||||
input: "foo",
|
||||
want: "any",
|
||||
},
|
||||
{
|
||||
name: "types",
|
||||
input: "main.SomeType",
|
||||
want: "models.SomeType",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user