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

[Feature request]: generate typescript types from react structs #463

Open
Manubi opened this issue Jan 29, 2025 · 1 comment
Open

[Feature request]: generate typescript types from react structs #463

Manubi opened this issue Jan 29, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@Manubi
Copy link

Manubi commented Jan 29, 2025

Is your feature request related to a problem? Please describe.

You have to define the types in the frontend (react) and on the server (rust).

Describe the solution you'd like

You could generate the frontend typings with a crate like ts-rs so you don't have to type them in the frontend. Instead just import them from the generated type file.

Describe alternatives you've considered

No response

Additional context

No response

@Manubi Manubi added the enhancement New feature or request label Jan 29, 2025
@Valerioageno Valerioageno changed the title [Feature request]: [Feature request]: generate typescript types from react structs Jan 29, 2025
@Valerioageno
Copy link
Member

Hey @Manubi thanks for raising this. We definitely should think to such solution. We already logged this task.

For me, the best would be to create a models/ folder in which putting all the rust structs with implementations like:

struct Sandwitch {}

impl Sandwitch {
    pub fn get_all() {}
    pub fn update() {}
    // Here all the implementation
}

So that we can easily use them in the server side rendering like:

#[tuono_lib::handler]
fn my_handler() -> Response {
    return Sandwitch::get_all();
}

and use it within react with something automatic like:

import type {Sandwitch} from 'tuono/models'

I'm available for suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants