Skip to content

Commit

Permalink
refactor(parser): use function parse_type_member_semicolon (#7018)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 30, 2024
1 parent b12691a commit e36a899
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions crates/oxc_parser/src/ts/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,7 @@ impl<'a> ParserImpl<'a> {
let type_parameters = self.parse_ts_type_parameters()?;
let (this_param, params) = self.parse_formal_parameters(FormalParameterKind::Signature)?;
let return_type = self.parse_ts_return_type_annotation(Kind::Colon, false)?;
self.bump(Kind::Comma);
self.bump(Kind::Semicolon);
self.parse_type_member_semicolon();
Ok(self.ast.ts_signature_call_signature_declaration(
self.end_span(span),
type_parameters,
Expand All @@ -1154,8 +1153,7 @@ impl<'a> ParserImpl<'a> {
let (key, computed) = self.parse_property_name()?;
let (this_param, params) = self.parse_formal_parameters(FormalParameterKind::Signature)?;
let return_type = self.parse_ts_return_type_annotation(Kind::Colon, false)?;
self.bump(Kind::Comma);
self.bump(Kind::Semicolon);
self.parse_type_member_semicolon();
Ok(self.ast.ts_signature_method_signature(
self.end_span(span),
key,
Expand All @@ -1175,8 +1173,7 @@ impl<'a> ParserImpl<'a> {
let (key, computed) = self.parse_property_name()?;
let (this_param, params) = self.parse_formal_parameters(FormalParameterKind::Signature)?;
let return_type = self.parse_ts_return_type_annotation(Kind::Colon, false)?;
self.bump(Kind::Comma);
self.bump(Kind::Semicolon);
self.parse_type_member_semicolon();
if let Some(return_type) = return_type.as_ref() {
self.error(diagnostics::a_set_accessor_cannot_have_a_return_type_annotation(
return_type.span,
Expand Down Expand Up @@ -1214,8 +1211,7 @@ impl<'a> ParserImpl<'a> {
else {
unreachable!()
};
self.bump(Kind::Comma);
self.bump(Kind::Semicolon);
self.parse_type_member_semicolon();
let call_signature = call_signature.unbox();
Ok(self.ast.ts_signature_method_signature(
self.end_span(span),
Expand All @@ -1230,8 +1226,7 @@ impl<'a> ParserImpl<'a> {
))
} else {
let type_annotation = self.parse_ts_type_annotation()?;
self.bump(Kind::Comma);
self.bump(Kind::Semicolon);
self.parse_type_member_semicolon();
Ok(self.ast.ts_signature_property_signature(
self.end_span(span),
computed,
Expand All @@ -1256,8 +1251,7 @@ impl<'a> ParserImpl<'a> {
}

let return_type = self.parse_ts_return_type_annotation(Kind::Colon, false)?;
self.bump(Kind::Comma);
self.bump(Kind::Semicolon);
self.parse_type_member_semicolon();

Ok(self.ast.ts_signature_construct_signature_declaration(
self.end_span(span),
Expand Down

0 comments on commit e36a899

Please sign in to comment.