Merge pull request #1092 from albert-sun/1091-export-bindings

Added TypeScript interface export for the window.go object
This commit is contained in:
Lea Anthony
2022-01-23 08:57:05 +11:00
committed by GitHub
2 changed files with 10 additions and 3 deletions
+3 -1
View File
@@ -129,7 +129,7 @@ func (b *Bindings) GenerateBackendTS(targetfile string) error {
store := b.db.store
var output bytes.Buffer
output.WriteString("interface go {\n")
output.WriteString("export interface go {\n")
var sortedPackageNames slicer.StringSlicer
for packageName := range store {
@@ -201,6 +201,8 @@ declare global {
func goTypeToJSDocType(input string) string {
switch true {
case input == "interface{}":
return "any"
case input == "string":
return "string"
case input == "error":
+7 -2
View File
@@ -56,6 +56,11 @@ func Test_goTypeToJSDocType(t *testing.T) {
input: "bool",
want: "boolean",
},
{
name: "interface{}",
input: "interface{}",
want: "any",
},
{
name: "[]byte",
input: "[]byte",
@@ -64,12 +69,12 @@ func Test_goTypeToJSDocType(t *testing.T) {
{
name: "[]int",
input: "[]int",
want: "Array.<number>",
want: "Array<number>",
},
{
name: "[]bool",
input: "[]bool",
want: "Array.<boolean>",
want: "Array<boolean>",
},
{
name: "anything else",