Skip to content

Commit

Permalink
chore: remove unused, always empty fields from TsPropertySignature
Browse files Browse the repository at this point in the history
TsPropertySignature can not have params, type params, or an initializer.
  • Loading branch information
lucacasonato committed May 14, 2024
1 parent 53e1ae2 commit 2d4f3e9
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 26 deletions.
5 changes: 0 additions & 5 deletions crates/swc_ecma_ast/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,8 @@ pub struct TsPropertySignature {
pub key: Box<Expr>,
pub computed: bool,
pub optional: bool,
#[cfg_attr(feature = "serde-impl", serde(default))]
pub init: Option<Box<Expr>>,
pub params: Vec<TsFnParam>,
#[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
pub type_ann: Option<Box<TsTypeAnn>>,
#[cfg_attr(feature = "serde-impl", serde(default))]
pub type_params: Option<Box<TsTypeParamDecl>>,
}

#[ast_node("TsGetterSignature")]
Expand Down
9 changes: 0 additions & 9 deletions crates/swc_ecma_codegen/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,6 @@ where
punct!("?");
}

emit!(n.type_params);

// punct!("(");
// self.emit_list(n.span, Some(&n.params), ListFormat::Parameters)?;
// punct!(")");
Expand All @@ -752,13 +750,6 @@ where
formatting_space!();
emit!(type_ann);
}

if let Some(init) = &n.init {
formatting_space!();
punct!("=");
formatting_space!();
emit!(init);
}
}

#[emitter]
Expand Down
3 changes: 0 additions & 3 deletions crates/swc_ecma_parser/src/parser/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,9 +1449,6 @@ impl<I: Tokens> Parser<I> {
readonly,
key,
optional,
init: None,
type_params: None,
params: vec![],
type_ann,
}))
}
Expand Down
3 changes: 0 additions & 3 deletions crates/swc_ecma_transforms_base/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,9 +1401,6 @@ impl<'a> VisitMut for Resolver<'a> {
self.with_child(ScopeKind::Fn, |child| {
child.in_type = true;

n.type_params.visit_mut_with(child);
n.init.visit_mut_with(child);
n.params.visit_mut_with(child);
n.type_ann.visit_mut_with(child);
});
}
Expand Down
3 changes: 0 additions & 3 deletions crates/swc_ecma_visit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,10 +1531,7 @@ define!({
pub key: Box<Expr>,
pub computed: bool,
pub optional: bool,
pub init: Option<Box<Expr>>,
pub params: Vec<TsFnParam>,
pub type_ann: Option<Box<TsTypeAnn>>,
pub type_params: Option<Box<TsTypeParamDecl>>,
}

pub struct TsGetterSignature {
Expand Down
2 changes: 0 additions & 2 deletions crates/swc_estree_ast/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ pub struct TSPropertySignature {
#[serde(default)]
pub type_annotation: Option<Box<TSTypeAnnotation>>,
#[serde(default)]
pub initializer: Option<Box<Expression>>,
#[serde(default)]
pub computed: Option<bool>,
#[serde(default)]
pub optional: Option<bool>,
Expand Down
1 change: 0 additions & 1 deletion crates/swc_estree_compat/src/babelify/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ impl Babelify for TsPropertySignature {
type_annotation: self
.type_ann
.map(|ann| Box::alloc().init(ann.babelify(ctx))),
initializer: self.init.map(|i| Box::alloc().init(i.babelify(ctx).into())),
computed: Some(self.computed),
optional: Some(self.optional),
readonly: Some(self.readonly),
Expand Down

0 comments on commit 2d4f3e9

Please sign in to comment.