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

don't generate unused functions in bindings #138

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MnlPhlp
Copy link

@MnlPhlp MnlPhlp commented Oct 19, 2024

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.

@@ -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
Copy link
Member

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.

Copy link
Author

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"]
Copy link
Member

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?

Copy link
Author

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.

Copy link
Member

@oscartbeaumont oscartbeaumont left a 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

@MnlPhlp
Copy link
Author

MnlPhlp commented Oct 21, 2024

Asked for some clarifications

I commented and made a small change. Is there anything else that is still wrong?

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