Skip to content

Commit

Permalink
chore: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Nov 3, 2024
1 parent 0406a1d commit d83d4ac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/swc_fast_ts_strip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ impl Visit for TsStrip {
self.strip_optional_mark(mark_index);
}

// It's dangerous to strip TypeScript modifiers if the key is computed, a
// generator, or `in`/`instanceof` keyword. However, it is safe to do so
// if the key is preceded by a `static` keyword or decorators.
//
// `public [foo]()`
// `; [foo]()`
//
Expand Down Expand Up @@ -764,6 +768,7 @@ impl Visit for TsStrip {
self.strip_definite_mark(mark_index);
}

// It's dangerous to strip types if the key is `get`, `set`, or `static`.
if n.value.is_none() {
if let Some(key) = n.key.as_ident() {
if matches!(key.sym.as_ref(), "get" | "set" | "static") {
Expand Down

0 comments on commit d83d4ac

Please sign in to comment.