-
Notifications
You must be signed in to change notification settings - Fork 158
Feature request: allow method of including [propName: string]: any to type #335
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
i have a struct with a generic i'm exporting as a typescript type, however due to this struct being a part of a library where the generic will be provided by the user, there's not really a good way to define a type. since it's flattened, what i'd want to do is include a [propName: string]: any to the end like the typescript docs recommend, but i don't see a clean way to do that. here's the closest i've been able to get:
#[derive(TS)]
pub struct AnyMarker {
#[ts(type = "any")]
foo: ()
}
impl Document for AnyMarker {
fn identifier() -> &'static str {
todo!()
}
fn title() -> &'static str {
todo!()
}
fn fields() -> Vec<EditorField> {
todo!()
}
fn validators(model: DataModel) -> HashMap<String, ValidatorFunction> {
todo!()
}
}
#[derive(Serialize, Deserialize, TS)]
#[ts(export)]
#[ts(concrete(D = AnyMarker))]
pub struct Item<D: Document> {
#[serde(rename = "__sc_id")]
pub id: String,
#[serde(rename = "__sc_created_at")]
pub created_at: DateTime<Utc>,
#[serde(rename = "__sc_modified_at")]
pub modified_at: DateTime<Utc>,
#[serde(rename = "__sc_published_at")]
pub published_at: Option<DateTime<Utc>>,
#[serde(flatten)]
pub inner: D,
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request