refactor(ast): remove duplicate TSNamedTupleMember representation (#3101)

Removes duplicate representation of a `TSTupleElement` which is a
`TSNamedTupleMember`.

Closes #3100.
This commit is contained in:
overlookmotel 2024-04-25 12:16:24 +01:00 committed by GitHub
parent 78875b79fe
commit 0185eb2edc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 2 additions and 8 deletions

View file

@ -299,7 +299,6 @@ pub enum TSTupleElement<'a> {
TSType(TSType<'a>),
TSOptionalType(Box<'a, TSOptionalType<'a>>),
TSRestType(Box<'a, TSRestType<'a>>),
TSNamedTupleMember(Box<'a, TSNamedTupleMember<'a>>),
}
#[derive(Debug, Hash)]

View file

@ -2748,7 +2748,6 @@ pub mod walk {
TSTupleElement::TSType(ty) => visitor.visit_ts_type(ty),
TSTupleElement::TSOptionalType(ty) => visitor.visit_ts_type(&ty.type_annotation),
TSTupleElement::TSRestType(ty) => visitor.visit_ts_type(&ty.type_annotation),
TSTupleElement::TSNamedTupleMember(ty) => visitor.visit_ts_type(&ty.element_type),
};
}

View file

@ -2900,7 +2900,6 @@ pub mod walk_mut {
TSTupleElement::TSType(ty) => visitor.visit_ts_type(ty),
TSTupleElement::TSOptionalType(ty) => visitor.visit_ts_type(&mut ty.type_annotation),
TSTupleElement::TSRestType(ty) => visitor.visit_ts_type(&mut ty.type_annotation),
TSTupleElement::TSNamedTupleMember(ty) => visitor.visit_ts_type(&mut ty.element_type),
};
}

View file

@ -509,9 +509,6 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSTupleElement<'a> {
p.print_str(b"...");
ts_type.type_annotation.gen(p, ctx);
}
TSTupleElement::TSNamedTupleMember(ts_type) => {
ts_type.gen(p, ctx);
}
}
}
}

View file

@ -74,9 +74,9 @@ impl<'a> SeparatedList<'a> for TSTupleElementList<'a> {
p.expect(Kind::Colon)?;
let element_type = p.parse_ts_type()?;
self.elements.push(TSTupleElement::TSNamedTupleMember(p.ast.alloc(
self.elements.push(TSTupleElement::TSType(TSType::TSNamedTupleMember(p.ast.alloc(
TSNamedTupleMember { span: p.end_span(span), element_type, label, optional },
)));
))));
return Ok(());
}