mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(ast): s/TSThisKeyword/TSThisType to align with estree
This commit is contained in:
parent
d08abc638e
commit
9087f71765
7 changed files with 11 additions and 11 deletions
|
|
@ -125,7 +125,7 @@ pub enum TSType<'a> {
|
|||
TSObjectKeyword(Box<'a, TSObjectKeyword>),
|
||||
TSStringKeyword(Box<'a, TSStringKeyword>),
|
||||
TSSymbolKeyword(Box<'a, TSSymbolKeyword>),
|
||||
TSThisKeyword(Box<'a, TSThisKeyword>),
|
||||
TSThisType(Box<'a, TSThisType>),
|
||||
TSUndefinedKeyword(Box<'a, TSUndefinedKeyword>),
|
||||
TSUnknownKeyword(Box<'a, TSUnknownKeyword>),
|
||||
TSVoidKeyword(Box<'a, TSVoidKeyword>),
|
||||
|
|
@ -380,7 +380,7 @@ pub struct TSSymbolKeyword {
|
|||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
pub struct TSThisKeyword {
|
||||
pub struct TSThisType {
|
||||
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
@ -692,7 +692,7 @@ pub struct TSTypePredicate<'a> {
|
|||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
pub enum TSTypePredicateName {
|
||||
Identifier(IdentifierName),
|
||||
This(TSThisKeyword),
|
||||
This(TSThisType),
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash)]
|
||||
|
|
|
|||
|
|
@ -1545,7 +1545,7 @@ impl<'a> AstBuilder<'a> {
|
|||
}
|
||||
|
||||
pub fn ts_this_keyword(&self, span: Span) -> TSType<'a> {
|
||||
TSType::TSThisKeyword(self.alloc(TSThisKeyword { span }))
|
||||
TSType::TSThisType(self.alloc(TSThisType { span }))
|
||||
}
|
||||
|
||||
pub fn ts_any_keyword(&self, span: Span) -> TSType<'a> {
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ impl<'a> GetSpan for TSType<'a> {
|
|||
Self::TSBooleanKeyword(t) => t.span,
|
||||
Self::TSSymbolKeyword(t) => t.span,
|
||||
Self::TSBigIntKeyword(t) => t.span,
|
||||
Self::TSThisKeyword(t) => t.span,
|
||||
Self::TSThisType(t) => t.span,
|
||||
Self::TSVoidKeyword(t) => t.span,
|
||||
Self::TSObjectKeyword(t) => t.span,
|
||||
Self::JSDocNullableType(t) => t.span,
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSType<'a> {
|
|||
Self::TSSymbolKeyword(_) => {
|
||||
p.print_str(b"symbol");
|
||||
}
|
||||
Self::TSThisKeyword(_) => {
|
||||
Self::TSThisType(_) => {
|
||||
p.print_str(b"this");
|
||||
}
|
||||
Self::TSUndefinedKeyword(_) => {
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ fn is_simple_type(ts_type: &TSType) -> bool {
|
|||
| TSType::TSArrayType(_)
|
||||
| TSType::TSUndefinedKeyword(_)
|
||||
| TSType::TSQualifiedName(_)
|
||||
| TSType::TSThisKeyword(_) => true,
|
||||
| TSType::TSThisType(_) => true,
|
||||
TSType::TSTypeReference(node) => {
|
||||
let type_name = TSTypeName::get_first_name(&node.type_name);
|
||||
if type_name.name.as_str() == "Array" {
|
||||
|
|
@ -395,7 +395,7 @@ fn get_ts_element_type_span(ts_type: &TSType) -> Option<Span> {
|
|||
TSType::TSUnknownKeyword(t) => Some(t.span),
|
||||
TSType::TSVoidKeyword(t) => Some(t.span),
|
||||
TSType::TSNullKeyword(t) => Some(t.span),
|
||||
TSType::TSThisKeyword(t) => Some(t.span),
|
||||
TSType::TSThisType(t) => Some(t.span),
|
||||
TSType::TSUndefinedKeyword(t) => Some(t.span),
|
||||
|
||||
TSType::TSArrayType(t) => Some(t.span),
|
||||
|
|
|
|||
|
|
@ -891,7 +891,7 @@ impl<'a> ParserImpl<'a> {
|
|||
let parameter_name = if self.at(Kind::This) {
|
||||
let span = self.start_span();
|
||||
self.bump_any();
|
||||
TSTypePredicateName::This(TSThisKeyword { span: self.end_span(span) })
|
||||
TSTypePredicateName::This(TSThisType { span: self.end_span(span) })
|
||||
} else {
|
||||
TSTypePredicateName::Identifier(self.parse_identifier_name()?)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -662,7 +662,7 @@ impl<'a> Format<'a> for TSType<'a> {
|
|||
TSType::TSObjectKeyword(v) => v.format(p),
|
||||
TSType::TSStringKeyword(v) => v.format(p),
|
||||
TSType::TSSymbolKeyword(v) => v.format(p),
|
||||
TSType::TSThisKeyword(v) => v.format(p),
|
||||
TSType::TSThisType(v) => v.format(p),
|
||||
TSType::TSUndefinedKeyword(v) => v.format(p),
|
||||
TSType::TSUnknownKeyword(v) => v.format(p),
|
||||
TSType::TSVoidKeyword(v) => v.format(p),
|
||||
|
|
@ -745,7 +745,7 @@ impl<'a> Format<'a> for TSSymbolKeyword {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Format<'a> for TSThisKeyword {
|
||||
impl<'a> Format<'a> for TSThisType {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
Doc::Str("this")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue