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: support tuple structs #46

Closed
archeoss opened this issue Oct 16, 2023 · 4 comments
Closed

Feature request: support tuple structs #46

archeoss opened this issue Oct 16, 2023 · 4 comments

Comments

@archeoss
Copy link

archeoss commented Oct 16, 2023

Case:

use tsync::tsync;

#[tsync]
pub struct Test(String);

fn main() {
    unimplemented!();
}

Output:

thread 'main' panicked at /home/archeoss/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/tsync-2.0.1/src/to_typescript/structs.rs:30:38:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@Wulf
Copy link
Owner

Wulf commented Oct 28, 2023

hey @archeoss, thanks for reporting this :)

Tuple structs aren't supported yet, would love a PR if you have the time!

An alias type should work though:

#[tsync::tsync]
pub type Test = String;

@archeoss
Copy link
Author

archeoss commented Oct 29, 2023

hey @archeoss, thanks for reporting this :)

Tuple structs aren't supported yet, would love a PR if you have the time!

I'll try to look into it in two weeks or so, I think. (or any time I have some free time available)

And yeah, type aliases work fine, I just wanted to report it in case someone else stumbles upon it.

@Wulf Wulf changed the title panic on newtype conversion Feature request: support tuple structs Oct 29, 2023
@Wulf
Copy link
Owner

Wulf commented Oct 29, 2023

Awesome, thanks. And just to clarify, we're aiming for something like this, right?

Input:
struct Todo(i32, String)

Output:
type Todo = [number, string]

@Wulf
Copy link
Owner

Wulf commented Oct 29, 2023

Ah, I just realized we have another issue about this #43. Going to close this, feel free to continue the discussion there

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