Minor TS cleanup #429
clippy
291 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 0 |
Warning | 291 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.80.0 (051478957 2024-07-21)
- cargo 1.80.0 (376290515 2024-07-16)
- clippy 0.1.80 (0514789 2024-07-21)
Annotations
Check warning on line 642 in specta-zod/src/lib.rs
github-actions / clippy
`panic` should not be present in production code
warning: `panic` should not be present in production code
--> specta-zod/src/lib.rs:642:22
|
642 | _ => panic!("unhandled literal type!"),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#panic
= note: requested on the command line with `-W clippy::panic`
Check warning on line 120 in specta-zod/src/lib.rs
github-actions / clippy
this expression always evaluates to true
warning: this expression always evaluates to true
--> specta-zod/src/lib.rs:120:47
|
120 | let prefix = match start_with_newline && !comments.is_empty() {
| ^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#const_is_empty
= note: `-W clippy::const-is-empty` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::const_is_empty)]`
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-zod` is missing `package.readme` metadata
warning: package `specta-zod` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-util` is missing `package.readme` metadata
warning: package `specta-util` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-typescript` is missing `package.readme` metadata
warning: package `specta-typescript` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-swift` is missing `package.readme` metadata
warning: package `specta-swift` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-serde` is missing `package.readme` metadata
warning: package `specta-serde` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-rust` is missing `package.readme` metadata
warning: package `specta-rust` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-openapi` is missing `package.readme` metadata
warning: package `specta-openapi` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-kotlin` is missing `package.readme` metadata
warning: package `specta-kotlin` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-go` is missing `package.readme` metadata
warning: package `specta-go` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta-datatype-from` is missing `package.readme` metadata
warning: package `specta-datatype-from` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
Check warning on line 1 in specta-zod/src/lib.rs
github-actions / clippy
package `specta` is missing `package.readme` metadata
warning: package `specta` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
= note: `-W clippy::cargo-common-metadata` implied by `-W clippy::cargo`
= help: to override `-W clippy::cargo` add `#[allow(clippy::cargo_common_metadata)]`
Check warning on line 11 in Cargo.toml
github-actions / clippy
lint group `cargo` has the same priority (-1) as a lint
warning: lint group `cargo` has the same priority (-1) as a lint
--> Cargo.toml:11:1
|
11 | cargo = { level = "warn", priority = -1 }
| ^^^^^
12 | unwrap_used = { level = "warn", priority = -1 }
| ----------- has the same priority as this lint
|
= note: the order of the lints in the table is ignored by Cargo
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lint_groups_priority
help: to have lints override the group set `cargo` to a lower priority
|
11 | cargo = { level = "warn", priority = -2 }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Check warning on line 10 in Cargo.toml
github-actions / clippy
lint group `all` has the same priority (-1) as a lint
warning: lint group `all` has the same priority (-1) as a lint
--> Cargo.toml:10:1
|
10 | all = { level = "warn", priority = -1 }
| ^^^
11 | cargo = { level = "warn", priority = -1 }
12 | unwrap_used = { level = "warn", priority = -1 }
| ----------- has the same priority as this lint
|
= note: the order of the lints in the table is ignored by Cargo
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lint_groups_priority
= note: `-W clippy::lint-groups-priority` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::lint_groups_priority)]`
help: to have lints override the group set `all` to a lower priority
|
10 | all = { level = "warn", priority = -2 }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Check warning on line 8 in specta-zod/src/context.rs
github-actions / clippy
field `0` is never read
warning: field `0` is never read
--> specta-zod/src/context.rs:8:18
|
8 | TypeExtended(Cow<'static, str>, ImplLocation),
| ------------ ^^^^^^^^^^^^^^^^^
| |
| field in this variant
|
= note: `#[warn(dead_code)]` on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
|
8 | TypeExtended((), ImplLocation),
| ~~
Check warning on line 780 in specta-typescript/src/lib.rs
github-actions / clippy
passing a unit value to a function
warning: passing a unit value to a function
--> specta-typescript/src/lib.rs:640:5
|
640 | / Ok(match &e.repr() {
641 | | EnumRepr::Untagged => {
642 | | let mut variants = e
643 | | .variants()
... |
779 | | }
780 | | })
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
help: move the expression in front of the call and replace it with the unit literal `()`
|
640 ~ match &e.repr() {
641 + EnumRepr::Untagged => {
642 + let mut variants = e
643 + .variants()
644 + .iter()
645 + .filter(|(_, variant)| !variant.skip())
646 + .map(|(name, variant)| {
647 + Ok(match variant.inner() {
648 + EnumVariants::Unit => NULL.to_string(),
649 + _ => inner_comments(
650 + ctx.clone(),
651 + variant.deprecated(),
652 + variant.docs(),
653 + enum_variant_datatype(
654 + ctx.with(PathItem::Variant(name.clone())),
655 + type_map,
656 + name.clone(),
657 + variant,
658 + )?
659 + .expect("Invalid Serde type"),
660 + true,
661 + ),
662 + })
663 + })
664 + .collect::<Result<Vec<_>>>()?;
665 + variants.dedup();
666 + s.push_str(&variants.join(" | "));
667 + }
668 + repr => {
669 + let mut variants = e
670 + .variants()
671 + .iter()
672 + .filter(|(_, variant)| !variant.skip())
673 + .map(|(variant_name, variant)| {
674 + let sanitised_name = sanitise_key(variant_name.clone(), true);
675 +
676 + Ok(inner_comments(
677 + ctx.clone(),
678 + variant.deprecated(),
679 + variant.docs(),
680 + match (repr, &variant.inner()) {
681 + (EnumRepr::Untagged, _) => unreachable!(),
682 + (EnumRepr::Internal { tag }, EnumVariants::Unit) => {
683 + format!("{{ {tag}: {sanitised_name} }}")
684 + }
685 + (EnumRepr::Internal { tag }, EnumVariants::Unnamed(tuple)) => {
686 + let fields = skip_fields(tuple.fields()).collect::<Vec<_>>();
687 +
688 + // This field is only required for `{ty}` not `[...]` so we only need to check when there one field
689 + let dont_join_ty = if tuple.fields().len() == 1 {
690 + let (_, ty) = fields.first().expect("checked length above");
691 + validate_type_for_tagged_intersection(
692 + ctx.clone(),
693 + (**ty).clone(),
694 + type_map,
695 + )?
696 + } else {
697 + false
698 + };
699 +
700 + let mut typ = String::new();
701 +
702 + unnamed_fields_datatype(ctx.clone(), &fields, type_map, &mut typ)?;
703 +
704 + if dont_join_ty {
705 + format!("({{ {tag}: {sanitised_name} }})")
706 + } else {
707 + // We wanna be sure `... & ... | ...` becomes `... & (... | ...)`
708 + if typ.contains('|') {
709 + typ = format!("({typ})");
710 + }
711 + format!("({{ {tag}: {sanitised_name} }} & {typ})")
712 + }
713 + }
714 + (EnumRepr::Internal { tag }, EnumVariants::Named(obj)) => {
715 + let mut fields = vec![format!("{tag}: {sanitised_name}")];
716 +
717 + for (name, field) in skip_fields_named(obj.fields()) {
718 + let mut other = String::new();
719 + object_field_to_ts(
720 + ctx.with(PathItem::Field(name.clone())),
721 + name.clone(),
722 + field,
723 + type_map,
724 + &mut other,
725 + )?;
726 + fields.push(other);
727 + }
728 +
729 + format!("{{ {} }}", fields.join("; "))
730 + }
731 + (EnumRepr::External, EnumVariants::Unit) => sanitised_name.to_string(),
732 + (EnumRepr::External, _) => {
733 + let ts_values = enum_variant_datatype(
734 + ctx.with(PathItem::Variant(variant_name.clone())),
735 + type_map,
736 + variant_name.clone(),
737 + variant,
738 + )?;
739 + let sanitised_name = sanitise_key(variant_name.clone(), false);
740 +
741 + match ts_values {
742 + Some(ts_values) => {
743 + format!("{{ {sanitised_name}: {ts_values} }}")
744 + }
745 + None => format!(r#""{sanitised_name}""#),
746 + }
747 + }
748 + (EnumRepr::Adjacent { tag, .. }, EnumVariants::Unit) => {
749 + format!("{{ {tag}: {sanitised_name} }}")
750 + }
751 + (EnumRepr::Adjacent { tag, content }, _) => {
752 + let ts_value = enum_variant_datatype(
753 + ctx.with(PathItem::Variant(variant_name.clone())),
754 + type_map,
755 + variant_name.clone(),
756 + variant,
757 + )?;
758 +
759 + let mut s = String::new();
760 +
761 + s.push_str("{ ");
762 +
763 + write!(s, "{tag}: {sanitised_name}")?;
764 + if let Some(ts_value) = ts_value {
765 + write!(s, "; {content}: {ts_value}")?;
766 + }
767 +
768 + s.push_str(" }");
769 +
770 + s
771 + }
772 + },
773 + true,
774 + ))
775 + })
776 + .collect::<Result<Vec<_>>>()?;
777 + variants.dedup();
778 + s.push_str(&variants.join(" | "));
779 + }
780 + };
781 + Ok(())
|
Check warning on line 486 in specta-typescript/src/lib.rs
github-actions / clippy
passing a unit value to a function
warning: passing a unit value to a function
--> specta-typescript/src/lib.rs:483:24
|
483 | return Ok(match named.tag().as_ref() {
| ________________________^
484 | | Some(tag) => write!(s, r#"{{ "{tag}": "{key}" }}"#)?,
485 | | None => write!(s, "Record<{STRING}, {NEVER}>")?,
486 | | });
| |__________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
help: move the expression in front of the call and replace it with the unit literal `()`
|
483 ~ return {
484 + match named.tag().as_ref() {
485 + Some(tag) => write!(s, r#"{{ "{tag}": "{key}" }}"#)?,
486 + None => write!(s, "Record<{STRING}, {NEVER}>")?,
487 + };
488 + Ok(())
489 ~ };
|
Check warning on line 548 in specta-typescript/src/lib.rs
github-actions / clippy
passing a unit value to a function
warning: passing a unit value to a function
--> specta-typescript/src/lib.rs:471:5
|
471 | / Ok(match &strct.fields() {
472 | | StructFields::Unit => s.push_str(NULL),
473 | | StructFields::Unnamed(unnamed) => unnamed_fields_datatype(
474 | | ctx,
... |
547 | | }
548 | | })
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
help: move the expression in front of the call and replace it with the unit literal `()`
|
471 ~ match &strct.fields() {
472 + StructFields::Unit => s.push_str(NULL),
473 + StructFields::Unnamed(unnamed) => unnamed_fields_datatype(
474 + ctx,
475 + &skip_fields(unnamed.fields()).collect::<Vec<_>>(),
476 + type_map,
477 + s,
478 + )?,
479 + StructFields::Named(named) => {
480 + let fields = skip_fields_named(named.fields()).collect::<Vec<_>>();
481 +
482 + if fields.is_empty() {
483 + return Ok(match named.tag().as_ref() {
484 + Some(tag) => write!(s, r#"{{ "{tag}": "{key}" }}"#)?,
485 + None => write!(s, "Record<{STRING}, {NEVER}>")?,
486 + });
487 + }
488 +
489 + let (flattened, non_flattened): (Vec<_>, Vec<_>) =
490 + fields.iter().partition(|(_, (f, _))| f.flatten());
491 +
492 + let mut field_sections = flattened
493 + .into_iter()
494 + .map(|(key, (field, ty))| {
495 + let mut s = String::new();
496 + datatype_inner(
497 + ctx.with(PathItem::Field(key.clone())),
498 + &FunctionResultVariant::Value(ty.clone()),
499 + type_map,
500 + &mut s,
501 + )
502 + .map(|_| {
503 + inner_comments(
504 + ctx.clone(),
505 + field.deprecated(),
506 + field.docs(),
507 + format!("({s})"),
508 + true,
509 + )
510 + })
511 + })
512 + .collect::<Result<Vec<_>>>()?;
513 +
514 + let mut unflattened_fields = non_flattened
515 + .into_iter()
516 + .map(|(key, field_ref)| {
517 + let (field, _) = field_ref;
518 +
519 + let mut other = String::new();
520 + object_field_to_ts(
521 + ctx.with(PathItem::Field(key.clone())),
522 + key.clone(),
523 + field_ref,
524 + type_map,
525 + &mut other,
526 + )?;
527 +
528 + Ok(inner_comments(
529 + ctx.clone(),
530 + field.deprecated(),
531 + field.docs(),
532 + other,
533 + true,
534 + ))
535 + })
536 + .collect::<Result<Vec<_>>>()?;
537 +
538 + if let Some(tag) = &named.tag() {
539 + unflattened_fields.push(format!("{tag}: \"{key}\""));
540 + }
541 +
542 + if !unflattened_fields.is_empty() {
543 + field_sections.push(format!("{{ {} }}", unflattened_fields.join("; ")));
544 + }
545 +
546 + s.push_str(&field_sections.join(" & "));
547 + }
548 + };
549 + Ok(())
|
Check warning on line 439 in specta-typescript/src/lib.rs
github-actions / clippy
passing a unit value to a function
warning: passing a unit value to a function
--> specta-typescript/src/lib.rs:396:5
|
396 | / Ok(match fields {
397 | | [(field, ty)] => {
398 | | let mut v = String::new();
399 | | datatype_inner(
... |
438 | | }
439 | | })
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
help: move the expression in front of the call and replace it with the unit literal `()`
|
396 ~ match fields {
397 + [(field, ty)] => {
398 + let mut v = String::new();
399 + datatype_inner(
400 + ctx.clone(),
401 + &FunctionResultVariant::Value((*ty).clone()),
402 + type_map,
403 + &mut v,
404 + )?;
405 + s.push_str(&inner_comments(
406 + ctx,
407 + field.deprecated(),
408 + field.docs(),
409 + v,
410 + true,
411 + ));
412 + }
413 + fields => {
414 + s.push('[');
415 +
416 + for (i, (field, ty)) in fields.iter().enumerate() {
417 + if i != 0 {
418 + s.push_str(", ");
419 + }
420 +
421 + let mut v = String::new();
422 + datatype_inner(
423 + ctx.clone(),
424 + &FunctionResultVariant::Value((*ty).clone()),
425 + type_map,
426 + &mut v,
427 + )?;
428 + s.push_str(&inner_comments(
429 + ctx.clone(),
430 + field.deprecated(),
431 + field.docs(),
432 + v,
433 + true,
434 + ));
435 + }
436 +
437 + s.push(']');
438 + }
439 + };
440 + Ok(())
|
Check warning on line 366 in specta-typescript/src/lib.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> specta-typescript/src/lib.rs:366:28
|
366 | s.push_str(&reference.name());
| ^^^^^^^^^^^^^^^^^ help: change this to: `reference.name()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
Check warning on line 364 in specta-typescript/src/lib.rs
github-actions / clippy
this expression creates a reference which is immediately dereferenced by the compiler
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> specta-typescript/src/lib.rs:364:30
|
364 | [] => s.push_str(&reference.name()),
| ^^^^^^^^^^^^^^^^^ help: change this to: `reference.name()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `-W clippy::needless-borrow` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::needless_borrow)]`
Check warning on line 386 in specta-typescript/src/lib.rs
github-actions / clippy
passing a unit value to a function
warning: passing a unit value to a function
--> specta-typescript/src/lib.rs:229:5
|
229 | / Ok(match &typ {
230 | | DataType::Any => s.push_str(ANY),
231 | | DataType::Unknown => s.push_str(UNKNOWN),
232 | | DataType::Primitive(p) => {
... |
385 | | DataType::Generic(ident) => s.push_str(&ident.to_string()),
386 | | })
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
= note: `-W clippy::unit-arg` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::unit_arg)]`
help: move the expression in front of the call and replace it with the unit literal `()`
|
229 ~ match &typ {
230 + DataType::Any => s.push_str(ANY),
231 + DataType::Unknown => s.push_str(UNKNOWN),
232 + DataType::Primitive(p) => {
233 + let ctx = ctx.with(PathItem::Type(p.to_rust_str().into()));
234 + let str = match p {
235 + primitive_def!(i8 i16 i32 u8 u16 u32 f32 f64) => NUMBER,
236 + primitive_def!(usize isize i64 u64 i128 u128) => match ctx.cfg.bigint {
237 + BigIntExportBehavior::String => STRING,
238 + BigIntExportBehavior::Number => NUMBER,
239 + BigIntExportBehavior::BigInt => BIGINT,
240 + BigIntExportBehavior::Fail => {
241 + return Err(ExportError::BigIntForbidden(ctx.export_path()));
242 + }
243 + BigIntExportBehavior::FailWithReason(reason) => {
244 + return Err(ExportError::Other(ctx.export_path(), reason.to_owned()))
245 + }
246 + },
247 + primitive_def!(String char) => STRING,
248 + primitive_def!(bool) => BOOLEAN,
249 + };
250 +
251 + s.push_str(str);
252 + }
253 + DataType::Literal(literal) => match literal {
254 + LiteralType::i8(v) => write!(s, "{v}")?,
255 + LiteralType::i16(v) => write!(s, "{v}")?,
256 + LiteralType::i32(v) => write!(s, "{v}")?,
257 + LiteralType::u8(v) => write!(s, "{v}")?,
258 + LiteralType::u16(v) => write!(s, "{v}")?,
259 + LiteralType::u32(v) => write!(s, "{v}")?,
260 + LiteralType::f32(v) => write!(s, "{v}")?,
261 + LiteralType::f64(v) => write!(s, "{v}")?,
262 + LiteralType::bool(v) => write!(s, "{v}")?,
263 + LiteralType::String(v) => write!(s, r#""{v}""#)?,
264 + LiteralType::char(v) => write!(s, r#""{v}""#)?,
265 + LiteralType::None => s.write_str(NULL)?,
266 + _ => unreachable!(),
267 + },
268 + DataType::Nullable(def) => {
269 + datatype_inner(
270 + ctx,
271 + &FunctionResultVariant::Value((**def).clone()),
272 + type_map,
273 + s,
274 + )?;
275 +
276 + let or_null = format!(" | {NULL}");
277 + if !s.ends_with(&or_null) {
278 + s.push_str(&or_null);
279 + }
280 + }
281 + DataType::Map(def) => {
282 + // We use this instead of `Record<K, V>` to avoid issues with circular references.
283 + s.push_str("{ [key in ");
284 + datatype_inner(
285 + ctx.clone(),
286 + &FunctionResultVariant::Value(def.key_ty().clone()),
287 + type_map,
288 + s,
289 + )?;
290 + s.push_str("]: ");
291 + datatype_inner(
292 + ctx.clone(),
293 + &FunctionResultVariant::Value(def.value_ty().clone()),
294 + type_map,
295 + s,
296 + )?;
297 + s.push_str(" }");
298 + }
299 + // We use `T[]` instead of `Array<T>` to avoid issues with circular references.
300 + DataType::List(def) => {
301 + let mut dt = String::new();
302 + datatype_inner(
303 + ctx,
304 + &FunctionResultVariant::Value(def.ty().clone()),
305 + type_map,
306 + &mut dt,
307 + )?;
308 +
309 + let dt = if (dt.contains(' ') && !dt.ends_with('}'))
310 + // This is to do with maintaining order of operations.
311 + // Eg `{} | {}` must be wrapped in parens like `({} | {})[]` but `{}` doesn't cause `{}[]` is valid
312 + || (dt.contains(' ') && (dt.contains('&') || dt.contains('|')))
313 + {
314 + format!("({dt})")
315 + } else {
316 + dt
317 + };
318 +
319 + if let Some(length) = def.length() {
320 + s.push('[');
321 +
322 + for n in 0..length {
323 + if n != 0 {
324 + s.push_str(", ");
325 + }
326 +
327 + s.push_str(&dt);
328 + }
329 +
330 + s.push(']');
331 + } else {
332 + write!(s, "{dt}[]")?;
333 + }
334 + }
335 + DataType::Struct(item) => struct_datatype(
336 + ctx.with(
337 + item.sid()
338 + .and_then(|sid| type_map.get(*sid))
339 + .and_then(|v| v.ext())
340 + .map(|v| PathItem::TypeExtended(item.name().clone(), *v.impl_location()))
341 + .unwrap_or_else(|| PathItem::Type(item.name().clone())),
342 + ),
343 + item.name(),
344 + item,
345 + type_map,
346 + s,
347 + )?,
348 + DataType::Enum(item) => {
349 + let mut ctx = ctx.clone();
350 + let cfg = ctx.cfg.clone().bigint(BigIntExportBehavior::Number);
351 + if item.skip_bigint_checks() {
352 + ctx.cfg = &cfg;
353 + }
354 +
355 + enum_datatype(
356 + ctx.with(PathItem::Variant(item.name().clone())),
357 + item,
358 + type_map,
359 + s,
360 + )?
361 + }
362 + DataType::Tuple(tuple) => s.push_str(&tuple_datatype(ctx, tuple, type_map)?),
363 + DataType::Reference(reference) => match &reference.generics()[..] {
364 + [] => s.push_str(&reference.name()),
365 + generics => {
366 + s.push_str(&reference.name());
367 + s.push('<');
368 +
369 + for (i, (_, v)) in generics.iter().enumerate() {
370 + if i != 0 {
371 + s.push_str(", ");
372 + }
373 +
374 + datatype_inner(
375 + ctx.with(PathItem::Type(reference.name().clone())),
376 + &FunctionResultVariant::Value(v.clone()),
377 + type_map,
378 + s,
379 + )?;
380 + }
381 +
382 + s.push('>');
383 + }
384 + },
385 + DataType::Generic(ident) => s.push_str(&ident.to_string()),
386 + };
387 + Ok(())
|
Check warning on line 137 in specta-typescript/src/lib.rs
github-actions / clippy
using `clone` on type `Option<&NamedDataTypeExt>` which implements the `Copy` trait
warning: using `clone` on type `Option<&NamedDataTypeExt>` which implements the `Copy` trait
--> specta-typescript/src/lib.rs:137:9
|
137 | ext.clone()
| ^^^^^^^^^^^ help: try removing the `clone` call: `ext`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
= note: `-W clippy::clone-on-copy` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::clone_on_copy)]`
Check warning on line 1 in specta-typescript/src/lib.rs
github-actions / clippy
package `specta-zod` is missing `package.readme` metadata
warning: package `specta-zod` is missing `package.readme` metadata
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata