bug: TS generated tests fail on struct with `serde_json::Value` type when running `cargo test`.
brochington opened this issue · 2 comments
brochington commented
Describe the bug
I have a struct the has a field of field_name: serde_json::Value
which runs and generates the correct Typescript type when I click the little "Run Test" button provided above the struct in VSCode/rust-analyzer. However, when I run cargo test
in the package, I receive the following error:
---- records::mystruct::export_bindings_mystruct stdout ----
thread 'records::mystruct::export_bindings_mystruct' panicked at <omitted>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ts-rs-8.1.0/src/export.rs:259:17:
internal error: entered unreachable code: The paths have been cleaned, no no '.' or '..' components are present
My struct:
#[derive(Debug, TS, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct MyStruct {
#[ts(type = "Uuid")]
pub id: Uuid,
pub json_content: serde_json::Value,
}
Note that if I remove the serde_json::Value
field, `cargo test runs just fine.
Version
8.1.0
NyxCode commented
Hey, thanks for opening an issue.
I currently can't reproduce this issue. Could you provide a minimal full example?
Here's what I tried:
use ts_rs::TS;
use uuid::Uuid;
use serde::{Serialize, Deserialize};
#[derive(Debug, TS, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct MyStruct {
#[ts(type = "Uuid")]
pub id: Uuid,
pub json_content: serde_json::Value,
}
[package]
name = "ts-rs-bug-test"
version = "0.1.0"
edition = "2021"
[dependencies]
ts-rs = { version = "8.1.0", features = ["serde-json-impl"] }
serde_json = "1"
uuid = { version = "*", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
escritorio-gustavo commented