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

New release? #356

Closed
gschier opened this issue Sep 17, 2024 · 5 comments · Fixed by #357
Closed

New release? #356

gschier opened this issue Sep 17, 2024 · 5 comments · Fixed by #357
Labels
enhancement New feature or request

Comments

@gschier
Copy link

gschier commented Sep 17, 2024

#316 was merged back in May but not yet released (according to CHANGELOG.md). Can we get a new release for this?

It's getting painful to re-export 70+ types.

CleanShot 2024-09-17 at 10 25 49@2x

@gschier gschier added the enhancement New feature or request label Sep 17, 2024
@gschier
Copy link
Author

gschier commented Sep 17, 2024

For context, I would love to configure it in build.rs like this:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("cargo:rustc-env=TS_RS_EXPORT_FILE=../../plugin-runtime-types/src/gen/index.ts");

    Ok(())
}

@Chaoses-Ib
Copy link

For #316, you can directly use the git repository as a workaround:

ts-rs = { version = "9.0.1", git = "https://github.com/Aleph-Alpha/ts-rs.git", rev = "9763ca019509fa4bbbfbaada1ad105c7192dee0b" }

For TS_RS_EXPORT_FILE, another TS generator tsync can do this. Though it's not actively maintained and has several problems.

@gustavo-shigueo
Copy link
Collaborator

#316 was merged back in May

Not quite. It was opened in may, but the merge happened in August 1st

Also, I think you mean TS_RS_EXPORT_DIR and the command you'd need is TS_RS_EXPORT_DIR=../../plugin-runtime-types/src/gen/index.ts cargo test

Using this, together with the change to Cargo.toml suggested by @Chaoses-Ib, your types should all be exported to your index file

@gustavo-shigueo gustavo-shigueo linked a pull request Sep 19, 2024 that will close this issue
@gschier
Copy link
Author

gschier commented Sep 19, 2024

@gustavo-shigueo setting TS_RS_EXPORT_DIR=../../plugin-runtime-types/src/gen/index.ts simply creates a directory called index.ts and puts the individual files there.

(Using the latest 10.0.0 release)

CleanShot 2024-09-19 at 13 15 09@2x

@gschier
Copy link
Author

gschier commented Sep 19, 2024

Okay, it seems to be working by keeping TS_RS_EXPORT_DIR=../../plugin-runtime-types/src/gen and adding export_to="index.ts" to each type.

#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
#[serde(default, rename_all = "camelCase")]
#[ts(export, export_to="index.ts")]
pub struct Settings {

The commit, if curious: yaakapp/app@53b8463

Thanks for the help y'all. This is an amazing project :)

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

Successfully merging a pull request may close this issue.

3 participants