mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
feat(transformer/typescript): keep imports if import specifiers is empty (#2058)
This commit is contained in:
parent
24ac957660
commit
b89e84cc2d
2 changed files with 10 additions and 8 deletions
|
|
@ -181,6 +181,9 @@ impl<'a> TypeScript<'a> {
|
||||||
}
|
}
|
||||||
ModuleDeclaration::ImportDeclaration(decl) => {
|
ModuleDeclaration::ImportDeclaration(decl) => {
|
||||||
let is_type = decl.import_kind.is_type();
|
let is_type = decl.import_kind.is_type();
|
||||||
|
let is_specifiers_empty =
|
||||||
|
decl.specifiers.as_ref().is_some_and(|s| s.is_empty());
|
||||||
|
|
||||||
if let Some(specifiers) = &mut decl.specifiers {
|
if let Some(specifiers) = &mut decl.specifiers {
|
||||||
specifiers.retain(|specifier| match specifier {
|
specifiers.retain(|specifier| match specifier {
|
||||||
ImportDeclarationSpecifier::ImportSpecifier(s) => {
|
ImportDeclarationSpecifier::ImportSpecifier(s) => {
|
||||||
|
|
@ -225,10 +228,11 @@ impl<'a> TypeScript<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if decl.import_kind.is_type()
|
if decl.import_kind.is_type()
|
||||||
|| decl
|
|| (!is_specifiers_empty
|
||||||
.specifiers
|
&& decl
|
||||||
.as_ref()
|
.specifiers
|
||||||
.is_some_and(|specifiers| specifiers.is_empty())
|
.as_ref()
|
||||||
|
.is_some_and(|specifiers| specifiers.is_empty()))
|
||||||
{
|
{
|
||||||
delete_indexes.push(index);
|
delete_indexes.push(index);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Passed: 312/1179
|
Passed: 314/1179
|
||||||
|
|
||||||
# All Passed:
|
# All Passed:
|
||||||
* babel-plugin-transform-numeric-separator
|
* babel-plugin-transform-numeric-separator
|
||||||
|
|
@ -832,7 +832,7 @@ Passed: 312/1179
|
||||||
* general/function-duplicate-name/input.js
|
* general/function-duplicate-name/input.js
|
||||||
* general/object/input.js
|
* general/object/input.js
|
||||||
|
|
||||||
# babel-plugin-transform-typescript (81/158)
|
# babel-plugin-transform-typescript (83/158)
|
||||||
* class/abstract-class-decorated/input.ts
|
* class/abstract-class-decorated/input.ts
|
||||||
* class/abstract-class-decorated-method/input.ts
|
* class/abstract-class-decorated-method/input.ts
|
||||||
* class/abstract-class-decorated-parameter/input.ts
|
* class/abstract-class-decorated-parameter/input.ts
|
||||||
|
|
@ -856,12 +856,10 @@ Passed: 312/1179
|
||||||
* exports/export=-to-cjs/input.ts
|
* exports/export=-to-cjs/input.ts
|
||||||
* function/overloads-exports/input.mjs
|
* function/overloads-exports/input.mjs
|
||||||
* imports/elide-injected/input.ts
|
* imports/elide-injected/input.ts
|
||||||
* imports/elide-no-import-specifiers/input.ts
|
|
||||||
* imports/enum-id/input.ts
|
* imports/enum-id/input.ts
|
||||||
* imports/enum-value/input.ts
|
* imports/enum-value/input.ts
|
||||||
* imports/import-named-type/input.ts
|
* imports/import-named-type/input.ts
|
||||||
* imports/import-named-type-default-and-named/input.ts
|
* imports/import-named-type-default-and-named/input.ts
|
||||||
* imports/import-removed-exceptions/input.ts
|
|
||||||
* imports/import=-module/input.ts
|
* imports/import=-module/input.ts
|
||||||
* imports/import=-module-to-cjs/input.ts
|
* imports/import=-module-to-cjs/input.ts
|
||||||
* imports/only-remove-type-imports/input.ts
|
* imports/only-remove-type-imports/input.ts
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue