File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -391,7 +391,7 @@ fn migrate_js_doc_tags(value: &mut serde_json::Value) {
391391 // should be migrated to "tsType". We distinguish from TsTypeDef
392392 // objects (which also have "kind") by checking that "repr" is absent.
393393 if !obj. contains_key ( "repr" ) {
394- let dominated_kind =
394+ let is_type_bearing_tag =
395395 obj. get ( "kind" ) . and_then ( |k| k. as_str ( ) ) . is_some_and ( |s| {
396396 matches ! (
397397 s,
@@ -407,7 +407,7 @@ fn migrate_js_doc_tags(value: &mut serde_json::Value) {
407407 )
408408 } ) ;
409409
410- if dominated_kind && let Some ( type_val) = obj. remove ( "type" ) {
410+ if is_type_bearing_tag && let Some ( type_val) = obj. remove ( "type" ) {
411411 match type_val {
412412 serde_json:: Value :: String ( s) => {
413413 obj. insert (
@@ -421,9 +421,10 @@ fn migrate_js_doc_tags(value: &mut serde_json::Value) {
421421 serde_json:: Value :: Null => {
422422 // Optional type that was null - leave tsType absent
423423 }
424- other => {
425- // Unexpected value, preserve it
426- obj. insert ( "type" . to_string ( ) , other) ;
424+ _ => {
425+ // Non-string, non-null "type" values can't be migrated;
426+ // drop them so deserialization doesn't fail on an
427+ // unexpected "type" key.
427428 }
428429 }
429430 }
You can’t perform that action at this time.
0 commit comments