mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
feat(transformer/typescript): remove verbatim_module_syntax option (#2796)
Remove `verbatim_module_syntax` option, Because Babel's [onlyRemoveTypeImports](https://babeljs.io/docs/babel-plugin-transform-typescript#onlyremovetypeimports) option same behavior with `verbatim_module_syntax` , You can see https://github.com/babel/babel/issues/15493#issuecomment-1466453493
This commit is contained in:
parent
b6e493bd78
commit
398a0346b3
2 changed files with 4 additions and 16 deletions
|
|
@ -104,8 +104,7 @@ impl<'a> Transformer<'a> {
|
|||
Self {
|
||||
ctx: ctx.clone(),
|
||||
decorators: Decorators::new(Rc::clone(&ast), ctx.clone(), &options),
|
||||
// TODO: pass verbatim_module_syntax from user config
|
||||
typescript: source_type.is_typescript().then(|| TypeScript::new(Rc::clone(&ast), ctx.clone(), false, &options)),
|
||||
typescript: source_type.is_typescript().then(|| TypeScript::new(Rc::clone(&ast), ctx.clone(), &options)),
|
||||
regexp_flags: RegexpFlags::new(Rc::clone(&ast), &options),
|
||||
// es2022
|
||||
es2022_class_static_block: es2022::ClassStaticBlock::new(Rc::clone(&ast), &options),
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use crate::{context::TransformerCtx, utils::is_valid_identifier, TransformOption
|
|||
pub struct TypeScript<'a> {
|
||||
ast: Rc<AstBuilder<'a>>,
|
||||
ctx: TransformerCtx<'a>,
|
||||
verbatim_module_syntax: bool,
|
||||
export_name_set: FxHashSet<Atom<'a>>,
|
||||
options: TypescriptOptions,
|
||||
namespace_arg_names: FxHashMap<Atom<'a>, usize>,
|
||||
|
|
@ -33,13 +32,11 @@ impl<'a> TypeScript<'a> {
|
|||
pub fn new(
|
||||
ast: Rc<AstBuilder<'a>>,
|
||||
ctx: TransformerCtx<'a>,
|
||||
verbatim_module_syntax: bool,
|
||||
options: &TransformOptions,
|
||||
) -> Self {
|
||||
Self {
|
||||
ast,
|
||||
ctx,
|
||||
verbatim_module_syntax,
|
||||
export_name_set: FxHashSet::default(),
|
||||
options: options.typescript.clone().unwrap_or_default(),
|
||||
namespace_arg_names: FxHashMap::default(),
|
||||
|
|
@ -140,7 +137,6 @@ impl<'a> TypeScript<'a> {
|
|||
});
|
||||
|
||||
if decl.export_kind.is_type()
|
||||
|| self.verbatim_module_syntax
|
||||
|| ((decl.declaration.is_none()
|
||||
|| decl.declaration.as_ref().is_some_and(|d| {
|
||||
d.modifiers().is_some_and(|modifiers| {
|
||||
|
|
@ -170,9 +166,7 @@ impl<'a> TypeScript<'a> {
|
|||
return false;
|
||||
}
|
||||
|
||||
if self.verbatim_module_syntax
|
||||
|| self.options.only_remove_type_imports
|
||||
{
|
||||
if self.options.only_remove_type_imports {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -182,9 +176,7 @@ impl<'a> TypeScript<'a> {
|
|||
|
||||
self.has_value_references(&s.local.name)
|
||||
}
|
||||
ImportDeclarationSpecifier::ImportDefaultSpecifier(s)
|
||||
if !self.verbatim_module_syntax =>
|
||||
{
|
||||
ImportDeclarationSpecifier::ImportDefaultSpecifier(s) => {
|
||||
if is_type {
|
||||
import_type_names.insert(s.local.name.clone());
|
||||
return false;
|
||||
|
|
@ -195,9 +187,7 @@ impl<'a> TypeScript<'a> {
|
|||
}
|
||||
self.has_value_references(&s.local.name)
|
||||
}
|
||||
ImportDeclarationSpecifier::ImportNamespaceSpecifier(s)
|
||||
if !self.verbatim_module_syntax =>
|
||||
{
|
||||
ImportDeclarationSpecifier::ImportNamespaceSpecifier(s) => {
|
||||
if is_type {
|
||||
import_type_names.insert(s.local.name.clone());
|
||||
}
|
||||
|
|
@ -208,7 +198,6 @@ impl<'a> TypeScript<'a> {
|
|||
|
||||
self.has_value_references(&s.local.name)
|
||||
}
|
||||
_ => true,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue