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

Don't warn about #[serde(with = "...")] #146

Closed
wants to merge 2 commits into from
Closed

Conversation

lynn
Copy link

@lynn lynn commented Mar 20, 2023

I had some code like this:

use chrono::serde::ts_seconds;
use chrono::DateTime;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Serialize, Deserialize, TS)]
#[ts(export)]
pub struct Test {
    #[ts(type = "number")]
    #[serde(with = "ts_seconds")]
    some_time: DateTime<Utc>,
}

ts-rs already handles this perfectly, as long as number really is the type that ts_seconds transforms the field to/from. However, it issues a warning about unrecognized attribute #[serde(with)]. So I wrote this patch that parses this attribute and silences the warning.

@escritorio-gustavo
Copy link
Contributor

escritorio-gustavo commented Jan 11, 2024

This has been implemented in #185 through the no-serde-warnings feature flag, which will disable all serde related warnings

@NyxCode
Copy link
Collaborator

NyxCode commented Jan 11, 2024

I think we still might want to eagerly parse the with attribute, and only emit a warning when the field does not have a #[ts(type = "..")] override.

@escritorio-gustavo
Copy link
Contributor

escritorio-gustavo commented Jan 26, 2024

and only emit a warning when the field does not have a #[ts(type = "..")] override.

Is it always the case that with requires type? If so, we could emit a compile_error! to make this mistake impossible to make

@escritorio-gustavo
Copy link
Contributor

Implemented in #280

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

Successfully merging this pull request may close these issues.

3 participants