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

result value and error transpiled to inline #212

Closed
Natejoestev opened this issue Jan 24, 2024 · 2 comments
Closed

result value and error transpiled to inline #212

Natejoestev opened this issue Jan 24, 2024 · 2 comments

Comments

@Natejoestev
Copy link

I noticed any type passed into a Result<> as value or error does not form into a separate type in the typescript definitions.

example code:

#[derive(serde::Serialize, specta::Type)]
enum MyValue {
  myThing {name: String}
}

#[tauri::command]
#[specta::specta]
fn my_func() -> Result<MyValue, boolean> {
  Ok(MyValue:myThing {
    name: "test".to_string()
  })
}

what it transpiles to:

export const commands = {
  async myFunc() : Promise<__Result__<{name:String}, boolean>> { .... }
}

notice how the result does not reference to a custom type.
how i would expect it to output:

export const commands = {
  async myFunc() : Promise<__Result__<MyValue, boolean>> { .... }
}

export type MyValue = { name: string };

thanks to icb in the tauri discord server for helping me discover this error.
I got lead to this because my type that i pass to the result i need to use other places in the frontend.

PS. the indenting is wacked up

@oscartbeaumont
Copy link
Owner

Which version of Tauri Specta/Specta are you using?

@oscartbeaumont
Copy link
Owner

Actually, I have a feeling this issue will be fixed by d3c7476 which is unreleased.

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

No branches or pull requests

2 participants