5
0
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:
Ariel 2022-03-08 21:44:32 +01:00 committed by GitHub
parent c5c0617c89
commit 9097c9086b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -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"
}

View File

@ -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) {