mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(ast): s/TSTypeOperatorType/TSTypeOperator to align with estree
This commit is contained in:
parent
9087f71765
commit
1634586934
8 changed files with 17 additions and 21 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,13 +206,13 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> 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 ");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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!()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue