Giter Site home page Giter Site logo

Comments (5)

amrbashir avatar amrbashir commented on July 26, 2024

sounds like an issue in your frontend code, what is the value of projectInfo.value in your frontend code?
it should look something like this:

{
  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

from tauri.

shadow3aaa avatar shadow3aaa commented on July 26, 2024

sounds like an issue in your frontend code, what is the value of projectInfo.value in your frontend code?
it should look something like this:

{
  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
  });

from tauri.

amrbashir avatar amrbashir commented on July 26, 2024

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:

  1. use repr(u16) but will require usage of serde_repr crate so serialization/deserialization could work properly, see https://serde.rs/enum-number.html
  2. change the typescript enum definition to match the serialization of rust enum, so it would look like this:
    enum Template {
      RustBinary = "rustBinary",
      RustLibrary = "rustLibrary",
      ...
    }

from tauri.

shadow3aaa avatar shadow3aaa commented on July 26, 2024

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:

  1. use repr(u16) but will require usage of serde_repr crate so serialization/deserialization could work properly, see https://serde.rs/enum-number.html
  2. change the typescript enum definition to match the serialization of rust enum, so it would look like this:
    enum Template {
      RustBinary = "rustBinary",
      RustLibrary = "rustLibrary",
      ...
    }

I have fixed it through the first way.
But I think this is really confusing for tauri user, maybe Tauri should provide a macro like #[derive(tauri::CommandArg)] to do these works(derive Serialize_repr, Deserialize_repr or Serialize, Deserialize traits, and add #[serde(rename_all = "camelCase")]) on-demand?

from tauri.

amrbashir avatar amrbashir commented on July 26, 2024

I think you're looking for https://github.com/oscartbeaumont/tauri-specta which generates typescript definitions for your based on your commands .

from tauri.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.