-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[bug] Failed to pass an enum as argument in command #10127
Comments
sounds like an issue in your frontend code, what is the value of {
name: "Project name",
template: "rustBinary"
} if it doesn't look like this, then your frontend is the issue, otherwise please provide a minimal repro and ping me |
It's something like this: enum Template {
RustBinary,
RustLibrary,
...
}
const projectInfo: ComputedRef<ProjectInfo> = computed(() => {
const template =
Template[projectTemplateInput.value as keyof typeof Template];
return {
name: projectName.value, // string
template, // Template
}); |
Typescript enums are not 1:1 equivalent of Rust enums, so you have to make sure they are equal, there is two ways you can do this:
|
I have fixed it through the first way. |
I think you're looking for https://github.com/oscartbeaumont/tauri-specta which generates typescript definitions for your based on your commands . |
Describe the bug
I have a command
project_manager_create_project
:And I tried to invoke it like this:
But it didn't work. So I open devtool and it prompts me with the error:
Uncaught (in promise) invalid args 'projectInfo' for command 'project_manager_create_project': invalid type: integer '0', expected string or map
.I searched for a few issues, like #6566, which looks like the same issue. So I tried the following solution (marking enum with #[repr(u16)]) but it didn't work
ProjectInfo struct:
Reproduction
No response
Expected behavior
No response
Full
tauri info
outputStack trace
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: