-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
don't generate unused functions in bindings #138
base: main
Are you sure you want to change the base?
Conversation
@@ -46,15 +52,11 @@ type __EventObj__<T> = { | |||
once: ( | |||
cb: TAURI_API_EVENT.EventCallback<T>, | |||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>; | |||
emit: T extends null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this change?
It also differs from the JS Doc alternative so they will need to match for this to be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be honest i don't know when/how this changed. i will undo the change.
@@ -21,15 +21,15 @@ rustdoc-args = ["--cfg", "docsrs"] | |||
default = [] | |||
derive = ["dep:tauri-specta-macros"] | |||
javascript = ["dep:specta-jsdoc"] | |||
typescript = ["dep:specta-typescript"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the changes in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the js.rs file has this use use specta_typescript::{js_doc, ExportError, Typescript};
So compiling without the specta_typescript dependency fails if only the javascript feature is set.
This is why the dependency is now not optional anymore and the 'dep:..' is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asked for some clarifications
I commented and made a small change. Is there anything else that is still wrong? |
When there are no events, part of the bindings file is unused.
In my case with
"noUnusedLocals": true,
in the tsconfig this lead to my project not compiling.This PR splits the global.ts and global.js into two parts and only includes the event related code if there are any events defined.
I tested this in my project, but I am not very used to ts/js. So feel free to point out any issues.