mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
fix(ast): change TSMappedType.type_annotation from TSTypeAnnotation to TSType (#2571)
Is ESTree, in that special case, there is no TSTypeAnnotation wrapper: (See `type X` in each) - [oxc playground](https://oxc-project.github.io/oxc/playground/?code=3YCAAIAWgICAgICAgICyHorESipoToAAwTlix58geR2%2Beeu9rZHQZOqK%2B%2BX85ZQ9ldchOoVw2oAm2qi9okF3bJ9o4l78ENP3f%2Bc%2B8cIK6Itp%2B3SIInU72Vk0%2FSqawy1VNV5zTgBr7gOpGtUZsvkc12Yp8MC2shel9fbpgDySpYsWdgDhf3jVlIA%3D) - [astexplorer TSESLint parser](9fc767f3a5) - [astexplorer Babel parser](9a4b02fae1) --------- Co-authored-by: Boshen <boshenc@gmail.com>
This commit is contained in:
parent
32028eb1c5
commit
78f30bc2db
5 changed files with 5 additions and 5 deletions
|
|
@ -836,7 +836,7 @@ pub struct TSMappedType<'a> {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
|
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
|
||||||
pub name_type: Option<TSType<'a>>,
|
pub name_type: Option<TSType<'a>>,
|
||||||
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
pub type_annotation: Option<TSType<'a>>,
|
||||||
pub optional: TSMappedTypeModifierOperator,
|
pub optional: TSMappedTypeModifierOperator,
|
||||||
pub readonly: TSMappedTypeModifierOperator,
|
pub readonly: TSMappedTypeModifierOperator,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1667,7 +1667,7 @@ impl<'a> AstBuilder<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
type_parameter: Box<'a, TSTypeParameter<'a>>,
|
type_parameter: Box<'a, TSTypeParameter<'a>>,
|
||||||
name_type: Option<TSType<'a>>,
|
name_type: Option<TSType<'a>>,
|
||||||
type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
type_annotation: Option<TSType<'a>>,
|
||||||
optional: TSMappedTypeModifierOperator,
|
optional: TSMappedTypeModifierOperator,
|
||||||
readonly: TSMappedTypeModifierOperator,
|
readonly: TSMappedTypeModifierOperator,
|
||||||
) -> TSType<'a> {
|
) -> TSType<'a> {
|
||||||
|
|
|
||||||
|
|
@ -1668,7 +1668,7 @@ pub trait Visit<'a>: Sized {
|
||||||
self.visit_ts_type(name);
|
self.visit_ts_type(name);
|
||||||
}
|
}
|
||||||
if let Some(type_annotation) = &ty.type_annotation {
|
if let Some(type_annotation) = &ty.type_annotation {
|
||||||
self.visit_ts_type_annotation(type_annotation);
|
self.visit_ts_type(type_annotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1667,7 +1667,7 @@ pub trait VisitMut<'a>: Sized {
|
||||||
self.visit_ts_type(name);
|
self.visit_ts_type(name);
|
||||||
}
|
}
|
||||||
if let Some(type_annotation) = &mut ty.type_annotation {
|
if let Some(type_annotation) = &mut ty.type_annotation {
|
||||||
self.visit_ts_type_annotation(type_annotation);
|
self.visit_ts_type(type_annotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -662,7 +662,7 @@ impl<'a> ParserImpl<'a> {
|
||||||
_ => TSMappedTypeModifierOperator::None,
|
_ => TSMappedTypeModifierOperator::None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let type_annotation = self.parse_ts_type_annotation()?;
|
let type_annotation = self.eat(Kind::Colon).then(|| self.parse_ts_type()).transpose()?;
|
||||||
self.bump(Kind::Semicolon);
|
self.bump(Kind::Semicolon);
|
||||||
self.expect(Kind::RCurly)?;
|
self.expect(Kind::RCurly)?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue