Skip to content
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
19 changes: 9 additions & 10 deletions tests/tests/bigints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ pub enum EnumWithInlineStructWithBigInt {

#[test]
fn test_bigint_types() {
// TODO: Fix errors
for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::default()).map_err(|e| e.to_string()), Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())));
for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::new()).map_err(|e| e.to_string()), Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())));
for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::new().bigint(BigIntExportBehavior::Fail)).map_err(|e| e.to_string()), Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())));
for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::default()).map_err(|e| e.to_string()), Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())));
for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::new()).map_err(|e| e.to_string()), Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())));
for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::new().bigint(BigIntExportBehavior::Fail)).map_err(|e| e.to_string()), Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())));

for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::new().bigint(BigIntExportBehavior::String)).map_err(|e| e.to_string()), Ok("string".into())));
for_bigint_types!(T -> |name| assert_eq!(crate::ts::inline::<T>(&Typescript::new().bigint(BigIntExportBehavior::Number)).map_err(|e| e.to_string()), Ok("number".into())));
Expand All @@ -72,22 +71,22 @@ fn test_bigint_types() {
// // // Check error messages are working correctly -> These tests second for `ExportPath` which is why they are so comprehensive
assert_eq!(
crate::ts::inline::<StructWithBigInt>(&Typescript::default()).map_err(|e| e.to_string()),
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())
);
assert_eq!(
crate::ts::inline::<StructWithStructWithBigInt>(&Typescript::default())
.map_err(|e| e.to_string()),
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())
);
assert_eq!(
crate::ts::inline::<StructWithStructWithStructWithBigInt>(&Typescript::default())
.map_err(|e| e.to_string()),
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())
);
assert_eq!(
crate::ts::inline::<EnumWithStructWithStructWithBigInt>(&Typescript::default())
.map_err(|e| e.to_string()),
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())
);
// TODO: This required `inline` to work better on `Option<T>`
// assert_eq!(
Expand All @@ -99,11 +98,11 @@ fn test_bigint_types() {
assert_eq!(
crate::ts::inline::<EnumWithStructWithStructWithBigInt>(&Typescript::default())
.map_err(|e| e.to_string()),
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())
);
assert_eq!(
crate::ts::inline::<EnumWithInlineStructWithBigInt>(&Typescript::default())
.map_err(|e| e.to_string()),
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. You can change this behavior by editing your `ExportConfiguration`!\n".into())
Err("Attempted to export \"\" but Specta configuration forbids exporting BigInt types (i64, u64, i128, u128) because we don't know if your se/deserializer supports it. If your using a serializer/deserializer that natively has support for BigInt types you can disable this warning by editing your `ExportConfiguration`!\n".into())
);
}
8 changes: 3 additions & 5 deletions tests/tests/macro/compile_error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ error[E0432]: unresolved import `specta::specta`
note: found an item that was configured out
--> $WORKSPACE/specta/src/lib.rs
|
| #[cfg(all(feature = "derive", feature = "function"))]
| -------------------- the item is gated behind the `function` feature
| #[cfg_attr(docsrs, doc(cfg(all(feature = "derive", feature = "function"))))]
| pub use specta_macros::specta;
| ^^^^^^
note: the item is gated here
--> $WORKSPACE/specta/src/lib.rs
|
| #[cfg(all(feature = "derive", feature = "function"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0601]: `main` function not found in crate `$CRATE`
--> tests/macro/compile_error.rs:110:20
Expand Down
19 changes: 13 additions & 6 deletions tests/tests/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,6 @@ fn typescript_types() {

// https://github.com/specta-rs/specta/issues/374
assert_ts!(Issue374, "{ foo?: boolean; bar?: boolean }");

// https://github.com/specta-rs/specta/issues/386
assert_ts!(Type, "never");
}

#[derive(Type)]
Expand Down Expand Up @@ -780,6 +777,16 @@ struct Issue374 {
bar: bool,
}

/// https://github.com/specta-rs/specta/issues/386
#[derive(specta::Type)]
enum Type {}

// https://github.com/specta-rs/specta/issues/386
// We put this test in a separate module because the parent module has `use specta::Type`,
// so it clashes with our user-defined `Type`.
mod type_type {
#[derive(specta::Type)]
enum Type {}

#[test]
fn typescript_types() {
assert_ts!(Type, "never");
}
}
Loading