diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 10ee027a6..95ea36d98 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -144,7 +144,7 @@ pub enum TSType<'a> { TSTemplateLiteralType(Box<'a, TSTemplateLiteralType<'a>>), TSTupleType(Box<'a, TSTupleType<'a>>), TSTypeLiteral(Box<'a, TSTypeLiteral<'a>>), - TSTypeOperatorType(Box<'a, TSTypeOperatorType<'a>>), + TSTypeOperatorType(Box<'a, TSTypeOperator<'a>>), TSTypePredicate(Box<'a, TSTypePredicate<'a>>), TSTypeQuery(Box<'a, TSTypeQuery<'a>>), TSTypeReference(Box<'a, TSTypeReference<'a>>), @@ -205,17 +205,17 @@ pub struct TSIntersectionType<'a> { #[derive(Debug, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))] #[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))] -pub struct TSTypeOperatorType<'a> { +pub struct TSTypeOperator<'a> { #[cfg_attr(feature = "serde", serde(flatten))] pub span: Span, - pub operator: TSTypeOperator, + pub operator: TSTypeOperatorOperator, pub type_annotation: TSType<'a>, } #[derive(Debug, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "lowercase"))] #[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))] -pub enum TSTypeOperator { +pub enum TSTypeOperatorOperator { Keyof, Unique, Readonly, diff --git a/crates/oxc_ast/src/ast_builder.rs b/crates/oxc_ast/src/ast_builder.rs index ff6f9f07b..2d308cb1a 100644 --- a/crates/oxc_ast/src/ast_builder.rs +++ b/crates/oxc_ast/src/ast_builder.rs @@ -1226,14 +1226,10 @@ impl<'a> AstBuilder<'a> { pub fn ts_type_operator_type( &self, span: Span, - operator: TSTypeOperator, + operator: TSTypeOperatorOperator, type_annotation: TSType<'a>, ) -> TSType<'a> { - TSType::TSTypeOperatorType(self.alloc(TSTypeOperatorType { - span, - operator, - type_annotation, - })) + TSType::TSTypeOperatorType(self.alloc(TSTypeOperator { span, operator, type_annotation })) } pub fn ts_array_type(&self, span: Span, element_type: TSType<'a>) -> TSType<'a> { diff --git a/crates/oxc_ast/src/visit.rs b/crates/oxc_ast/src/visit.rs index 0224e7dd8..61a4bb719 100644 --- a/crates/oxc_ast/src/visit.rs +++ b/crates/oxc_ast/src/visit.rs @@ -1651,7 +1651,7 @@ pub trait Visit<'a>: Sized { } } - fn visit_ts_type_operator_type(&mut self, ty: &TSTypeOperatorType<'a>) { + fn visit_ts_type_operator_type(&mut self, ty: &TSTypeOperator<'a>) { self.visit_ts_type(&ty.type_annotation); } diff --git a/crates/oxc_ast/src/visit_mut.rs b/crates/oxc_ast/src/visit_mut.rs index 584d733d4..00871c106 100644 --- a/crates/oxc_ast/src/visit_mut.rs +++ b/crates/oxc_ast/src/visit_mut.rs @@ -1649,7 +1649,7 @@ pub trait VisitMut<'a>: Sized { } } - fn visit_ts_type_operator_type(&mut self, ty: &mut TSTypeOperatorType<'a>) { + fn visit_ts_type_operator_type(&mut self, ty: &mut TSTypeOperator<'a>) { self.visit_ts_type(&mut ty.type_annotation); } diff --git a/crates/oxc_codegen/src/gen_ts.rs b/crates/oxc_codegen/src/gen_ts.rs index d22eb554e..7c2fff1e5 100644 --- a/crates/oxc_codegen/src/gen_ts.rs +++ b/crates/oxc_codegen/src/gen_ts.rs @@ -206,13 +206,13 @@ impl<'a, const MINIFY: bool> Gen for TSType<'a> { } Self::TSTypeOperatorType(decl) => { match decl.operator { - TSTypeOperator::Keyof => { + TSTypeOperatorOperator::Keyof => { p.print_str(b"keyof "); } - TSTypeOperator::Unique => { + TSTypeOperatorOperator::Unique => { p.print_str(b"unique "); } - TSTypeOperator::Readonly => { + TSTypeOperatorOperator::Readonly => { p.print_str(b"readonly "); } } diff --git a/crates/oxc_linter/src/rules/typescript/array_type.rs b/crates/oxc_linter/src/rules/typescript/array_type.rs index 37437c8d3..a962aca37 100644 --- a/crates/oxc_linter/src/rules/typescript/array_type.rs +++ b/crates/oxc_linter/src/rules/typescript/array_type.rs @@ -1,5 +1,5 @@ use oxc_ast::{ - ast::{TSType, TSTypeName, TSTypeOperator, TSTypeReference}, + ast::{TSType, TSTypeName, TSTypeOperatorOperator, TSTypeReference}, AstKind, }; use oxc_diagnostics::{ @@ -148,7 +148,7 @@ fn check( } if let TSType::TSTypeOperatorType(ts_operator_type) = &type_annotation { - if matches!(&ts_operator_type.operator, TSTypeOperator::Readonly) { + if matches!(&ts_operator_type.operator, TSTypeOperatorOperator::Readonly) { if let TSType::TSArrayType(array_type) = &ts_operator_type.type_annotation { check_and_report_error_generic( readonly_config, diff --git a/crates/oxc_parser/src/ts/types.rs b/crates/oxc_parser/src/ts/types.rs index c1deb0d6d..fded11897 100644 --- a/crates/oxc_parser/src/ts/types.rs +++ b/crates/oxc_parser/src/ts/types.rs @@ -304,9 +304,9 @@ impl<'a> ParserImpl<'a> { } let operator = match self.cur_kind() { - Kind::KeyOf => Some(TSTypeOperator::Keyof), - Kind::Unique => Some(TSTypeOperator::Unique), - Kind::Readonly => Some(TSTypeOperator::Readonly), + Kind::KeyOf => Some(TSTypeOperatorOperator::Keyof), + Kind::Unique => Some(TSTypeOperatorOperator::Unique), + Kind::Readonly => Some(TSTypeOperatorOperator::Readonly), _ => None, }; diff --git a/crates/oxc_prettier/src/format/mod.rs b/crates/oxc_prettier/src/format/mod.rs index 09a2bd1e1..8153d381a 100644 --- a/crates/oxc_prettier/src/format/mod.rs +++ b/crates/oxc_prettier/src/format/mod.rs @@ -870,7 +870,7 @@ impl<'a> Format<'a> for TSTypeLiteral<'a> { } } -impl<'a> Format<'a> for TSTypeOperatorType<'a> { +impl<'a> Format<'a> for TSTypeOperator<'a> { fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> { line!() }