From 75ba4a9e7a5c6d155e9105c3962a50cdf22857af Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:30:26 +0000 Subject: [PATCH] refactor(transformer): use `NONE` in AST builder calls (#7751) Pure refactor. `NONE` is shorter than `None::>`. --- .../src/common/arrow_function_converter.rs | 2 +- .../src/common/helper_loader.rs | 21 ++++++------------- crates/oxc_transformer/src/typescript/enum.rs | 6 +++--- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/crates/oxc_transformer/src/common/arrow_function_converter.rs b/crates/oxc_transformer/src/common/arrow_function_converter.rs index b2fb0085115f1..295484f881cf0 100644 --- a/crates/oxc_transformer/src/common/arrow_function_converter.rs +++ b/crates/oxc_transformer/src/common/arrow_function_converter.rs @@ -565,7 +565,7 @@ impl<'a> ArrowFunctionConverter<'a> { arrow_function_expr.r#async, false, arrow_function_expr.type_parameters, - None::>, + NONE, arrow_function_expr.params, arrow_function_expr.return_type, Some(body), diff --git a/crates/oxc_transformer/src/common/helper_loader.rs b/crates/oxc_transformer/src/common/helper_loader.rs index 60a783e2679a6..c55f64c615bab 100644 --- a/crates/oxc_transformer/src/common/helper_loader.rs +++ b/crates/oxc_transformer/src/common/helper_loader.rs @@ -71,7 +71,10 @@ use rustc_hash::FxHashMap; use serde::Deserialize; use oxc_allocator::{String as ArenaString, Vec as ArenaVec}; -use oxc_ast::ast::{Argument, CallExpression, Expression, TSTypeParameterInstantiation}; +use oxc_ast::{ + ast::{Argument, CallExpression, Expression}, + NONE, +}; use oxc_semantic::{ReferenceFlags, SymbolFlags}; use oxc_span::{Atom, Span, SPAN}; use oxc_traverse::{BoundIdentifier, TraverseCtx}; @@ -210,13 +213,7 @@ impl<'a> TransformCtx<'a> { ctx: &mut TraverseCtx<'a>, ) -> CallExpression<'a> { let callee = self.helper_load(helper, ctx); - ctx.ast.call_expression( - span, - callee, - None::>, - arguments, - false, - ) + ctx.ast.call_expression(span, callee, NONE, arguments, false) } /// Same as [`TransformCtx::helper_call`], but returns a `CallExpression` wrapped in an `Expression`. @@ -228,13 +225,7 @@ impl<'a> TransformCtx<'a> { ctx: &mut TraverseCtx<'a>, ) -> Expression<'a> { let callee = self.helper_load(helper, ctx); - ctx.ast.expression_call( - span, - callee, - None::>, - arguments, - false, - ) + ctx.ast.expression_call(span, callee, NONE, arguments, false) } /// Load a helper function and return a callee expression. diff --git a/crates/oxc_transformer/src/typescript/enum.rs b/crates/oxc_transformer/src/typescript/enum.rs index 7733f22b749d1..e761be08725f9 100644 --- a/crates/oxc_transformer/src/typescript/enum.rs +++ b/crates/oxc_transformer/src/typescript/enum.rs @@ -106,10 +106,10 @@ impl<'a> TypeScriptEnum<'a> { false, false, false, - None::, - None::, + NONE, + NONE, params, - None::, + NONE, Some(body), func_scope_id, ));