Skip to content

feat: handle JSDoc for ts type literals #561

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

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lazy_static! {
static ref JS_DOC_TAG_TYPED_RE: Regex = Regex::new(r"(?s)^\s*@(enum|extends|augments|this|type|default)\s+\{([^}]+)\}(?:\s+(.+))?").unwrap();
}

#[derive(Debug, Default, Clone, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)]
pub struct JsDoc {
#[serde(skip_serializing_if = "Option::is_none", default)]
pub doc: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@ fn parse_json_module_type(value: &serde_json::Value) -> TsTypeDef {
.iter()
.map(|(key, value)| LiteralPropertyDef {
name: key.to_string(),
js_doc: Default::default(),
ts_type: Some(parse_json_module_type(value)),
params: Vec::new(),
readonly: false,
Expand Down
6 changes: 6 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ async fn json_module() {
"methods": [],
"properties": [{
"name": "a",
"jsDoc": {},
"params": [],
"computed": false,
"optional": false,
Expand All @@ -954,6 +955,7 @@ async fn json_module() {
"typeParams": []
}, {
"name": "b",
"jsDoc": {},
"params": [],
"computed": false,
"optional": false,
Expand All @@ -968,6 +970,7 @@ async fn json_module() {
"typeParams": []
}, {
"name": "c",
"jsDoc": {},
"params": [],
"computed": false,
"optional": false,
Expand All @@ -979,6 +982,7 @@ async fn json_module() {
"typeParams": []
}, {
"name": "d",
"jsDoc": {},
"params": [],
"computed": false,
"optional": false,
Expand All @@ -994,6 +998,7 @@ async fn json_module() {
"typeParams": []
}, {
"name": "e",
"jsDoc": {},
"params": [],
"computed": false,
"optional": false,
Expand All @@ -1004,6 +1009,7 @@ async fn json_module() {
"methods": [],
"properties": [{
"name": "a",
"jsDoc": {},
"params": [],
"computed": false,
"optional": false,
Expand Down
Loading
Loading