-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Optional types don't appear to generate correct Typescript types without a serde skip_serializing_if annotation.
#[derive(Debug, Clone, Deserialize, reflectapi::Input)]
#[serde(deny_unknown_fields)]
pub struct ARequest {
pub reflect_option: reflectapi::Option<String>,
#[serde(default, skip_serializing_if = "reflectapi::Option::is_undefined")]
pub annotated_reflect_option: reflectapi::Option<String>,
pub std_option: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotated_std_option: Option<String>,
}Produces the following typescript:
interface ARequest {
reflect_option: string | null | undefined;
annotated_reflect_option?: string | null | undefined;
std_option: string | null;
annotated_std_option?: string | null;
}Assuming the first option is the recommended way to define optional types in reflectapi, the generated Typescript interface still requires a reflect_option to be included when defining an ARequest:
Metadata
Metadata
Assignees
Labels
No labels
