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: rust_decimal::Decimal TS implementation #272

Open
seanpianka opened this issue Mar 19, 2024 · 2 comments
Open

Feature request: rust_decimal::Decimal TS implementation #272

seanpianka opened this issue Mar 19, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@seanpianka
Copy link

Is your feature request related to a problem? Please describe.
My project uses rust_decimal instead of bigdecimal, which seems to be more popular. It might be helpful to provide an implementation for this as well.

Describe the solution you'd like
Provide an implementation of TS for rust_decimal::Decimal, enabled via "rust-decimal-impl" (or omit the first dash)

Describe alternatives you've considered
Downstream packages supply some manual implementation or fallback?

Additional context
I recently began using the crate, so perhaps this addition is unnecessary.

@seanpianka seanpianka added the enhancement New feature or request label Mar 19, 2024
@seanpianka seanpianka changed the title Feature request: rust_decimal::Decimal implementation Feature request: rust_decimal::Decimal TS implementation Mar 19, 2024
@NyxCode
Copy link
Collaborator

NyxCode commented Mar 19, 2024

Hey! Definetely something we can add in the future!

In the meantime, you can either use

  • a type override (specifying the typescript type manually): #[ts(type = "number")] field: Decimal
  • or, if your TS equivalent of Decimal is more complicated than number, use #[ts(as = ..)]

@seanpianka
Copy link
Author

I've opened a PR that should ideally resolve this. It uses a specific feature flag for Decimal formatting that my particular project uses (and which their documentation describes as "flexible"), however this may not be appropriate for everyone elses' projects.

Potentially we can add a feature flags for each of the available representations. e.g., rustdecimal-with-serde-str-impl, rustdecimal-serde-str-impl, rustdecimal-with-serde-float-impl, rustdecimal-serde-float-impl, serde-with-arbitrary-precision, rustdecimal-serde-arbitrary-precision-impl, etc.

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.

2 participants