Skip to content

Feature request: add an attribute to allow for types defined in ts only #426

@legomind

Description

@legomind

I am retriving records from a database, and one or more of the columns is a json datatype stored in a single column. I represent this using the type JsonValue, which wraps serde_json::Value.

Right now, the following works just fine, but results in the SomeStruct type having a field with an unknown type.

pub struct SomeStruct {
    #[ts(type="unknown")]
    pub questionare_results: JsonValue,
}

#[repr(transparent)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct JsonValue(pub serde_json::Value);
export type SomeStruct = { questionare_results: unknown, };

Somthing like this would be ideal:

pub struct SomeStruct {
    #[ts(type="QuestionareResults", importedFrom="../QuestionareResults.ts")]
    pub questionare_results: JsonValue,
}
import type { QuestionareResults } from "../QuestionareResults.ts"
export type SomeStruct = { questionare_results: QuestionareResults, };

Perhaps a default import as well?

pub struct SomeStruct {
    #[ts(defaultType="QuestionareResults", importedFrom="../QuestionareResults.ts")]
    pub questionare_results: JsonValue,
}
import type QuestionareResults from "../QuestionareResults.ts"
export type SomeStruct = { questionare_results: QuestionareResults, };

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions