Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TypeScript interface export for the window.go object #1092

Merged
merged 3 commits into from
Jan 22, 2022
Merged

Added TypeScript interface export for the window.go object #1092

merged 3 commits into from
Jan 22, 2022

Conversation

albert-sun
Copy link
Contributor

@albert-sun albert-sun commented Jan 22, 2022

The wailsjs/runtime/runtime.d.ts already has the window.runtime interface exported by default. I changed one line of code to add an export for the window.go interface within wailsjs/go/bindings.d.ts for linting purposes (the compiled JavaScript previously correctly referenced window.go during runtime even with the linting error).

The test located in generate_test.go failed as well but seems to be a false positive - it seemed to give the same error both before and after the change so I fixed it. Here's the original failure output when running go test in the directory:

--- FAIL: Test_goTypeToJSDocType (0.00s)
    --- FAIL: Test_goTypeToJSDocType/[]int (0.00s)
        generate_test.go:83: goTypeToJSDocType() = Array<number>, want Array.<number>
    --- FAIL: Test_goTypeToJSDocType/[]bool (0.00s)
        generate_test.go:83: goTypeToJSDocType() = Array<boolean>, want Array.<boolean>
FAIL
exit status 1
FAIL    github.com/wailsapp/wails/v2/internal/binding   0.006s

@leaanthony
Copy link
Member

Thanks for identifying and taking time to fix this issue. I think it looks fine but just wondering if it affects the JSDoc, which we do output. Would the [] syntax mentioned on this thread work for both you think? https://stackoverflow.com/questions/32295263/how-to-document-an-array-of-objects-in-jsdoc

@albert-sun
Copy link
Contributor Author

It looks like either works for documentation purposes reading https://jsdoc.app/tags-type.html (under the sub-heading titled "An array of MyClass instances."). Also, the stray period from the tests seems to be a result of inconsistent JSDoc guidelines which have changed over the years, see: https://stackoverflow.com/questions/47822791/why-does-jsdoc-allow-both-arraystring-and-array-string-and-is-one-better-th

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this :-)

@wailsapp wailsapp deleted a comment from albert-sun Jan 22, 2022
@leaanthony leaanthony merged commit cab2682 into wailsapp:master Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants