Skip to content

Commit

Permalink
fix: remove path handling from transform
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Feb 13, 2024
1 parent 981dfea commit 710ebbd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
16 changes: 2 additions & 14 deletions src/fast_check/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,10 @@ impl CommentsMut {
}
}

pub struct FastCheckDtsFile {
pub text: String,
pub specifier: ModuleSpecifier,
}

pub struct FastCheckModule {
pub module_info: ModuleInfo,
pub text: String,
pub dts: Option<FastCheckDtsFile>,
pub dts: Option<String>,
pub source_map: Vec<u8>,
}

Expand Down Expand Up @@ -212,14 +207,7 @@ pub fn transform(
},
)?;

let mut path = specifier.to_file_path().unwrap();
path.set_extension("d.ts");
let dts_specifier = ModuleSpecifier::from_file_path(path).unwrap();

Some(FastCheckDtsFile {
text,
specifier: dts_specifier,
})
Some(text)
} else {
None
};
Expand Down
13 changes: 3 additions & 10 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ pub struct FastCheckTypeModule {
pub dependencies: IndexMap<String, Dependency>,
pub source: Arc<str>,
pub source_map: Arc<[u8]>,
pub dts: Option<FastCheckDtsModule>,
pub dts: Option<String>,
}

#[derive(Debug, Clone, Serialize)]
Expand Down Expand Up @@ -3993,14 +3993,7 @@ impl<'a, 'graph> Builder<'a, 'graph> {
dependencies,
source: fast_check_module.text.into(),
source_map: fast_check_module.source_map.into(),
dts: if let Some(dts_file) = fast_check_module.dts {
Some(FastCheckDtsModule {
source: dts_file.text.into(),
specifier: dts_file.specifier,
})
} else {
None
},
dts: fast_check_module.dts,
}))
}
Err(diagnostic) => FastCheckTypeModuleSlot::Error(diagnostic),
Expand Down Expand Up @@ -5119,7 +5112,7 @@ mod tests {
module.fast_check.clone().unwrap()
{
assert_eq!(
fsm.dts.unwrap().source.to_string().trim(),
fsm.dts.unwrap().to_string().trim(),
"export function add(a: number, b: number): number;"
);
} else {
Expand Down

0 comments on commit 710ebbd

Please sign in to comment.