Skip to content

Commit

Permalink
chore: Remove the generic type marker.
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Jul 5, 2024
1 parent fff9efa commit 60ec5ce
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crates/swc_fast_ts_strip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ pub fn operate(
return Err(anyhow::anyhow!("failed to parse"));
}

let mut replacements = vec![];
// Strip typescript types
program.visit_with(&mut TsStrip {
replacements: &mut replacements,
});
let mut ts_strip = TsStrip::default();
program.visit_with(&mut ts_strip);

let mut replacements = ts_strip.replacements;

if replacements.is_empty() {
return Ok(fm.src.to_string());
Expand All @@ -107,17 +107,18 @@ pub fn operate(
Ok(code)
}

struct TsStrip<'a> {
replacements: &'a mut Vec<(BytePos, BytePos)>,
#[derive(Default)]
struct TsStrip {
replacements: Vec<(BytePos, BytePos)>,
}

impl TsStrip<'_> {
impl TsStrip {
fn add_replacement(&mut self, span: Span) {
self.replacements.push((span.lo, span.hi));
}
}

impl Visit for TsStrip<'_> {
impl Visit for TsStrip {
fn visit_decorator(&mut self, n: &Decorator) {
HANDLER.with(|handler| {
handler.span_err(n.span, "Decorators are not supported");
Expand Down

0 comments on commit 60ec5ce

Please sign in to comment.