5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 01:13:03 +08:00

fix: fixes TypeScript generated typings issues with interfaces and Promises (#647)

This commit is contained in:
Igor Minin 2021-04-02 23:04:59 +03:00 committed by GitHub
parent a2f16aba9b
commit 3f0a7cb43d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,15 +115,15 @@ func (b *Manager) generateTypescriptDefinitions() error {
for structname, methodList := range b.structList {
structname = strings.SplitN(structname, ".", 2)[1]
output.WriteString(fmt.Sprintf("Interface %s {\n", structname))
output.WriteString(fmt.Sprintf("interface %s {\n", structname))
for _, method := range methodList {
output.WriteString(fmt.Sprintf("\t%s: (...args : any[]) => Promise\n", method))
output.WriteString(fmt.Sprintf("\t%s(...args : any[]):Promise<any>\n", method))
}
output.WriteString("}\n")
}
output.WriteString("\n")
output.WriteString("Interface Backend {\n")
output.WriteString("interface Backend {\n")
for structname := range b.structList {
structname = strings.SplitN(structname, ".", 2)[1]
@ -136,7 +136,8 @@ declare global {
interface Window {
backend: Backend;
}
}`
}
export {};`
output.WriteString(globals)
b.log.Info("Written Typescript file: " + typescriptDefinitionFilename)