Skip to content

Commit

Permalink
fix(es/typescript): Correctly handle deep import chains (swc-project#…
Browse files Browse the repository at this point in the history
…9487)

**Related issue:**

- Closes swc-project#9486
  • Loading branch information
magic-akari committed Aug 22, 2024
1 parent 1121bc0 commit 50d70d3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-taxis-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
swc_ecma_transforms_typescript: patch
---

fix(es/typescript): Correctly handle deep import chains
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ impl UsageCollect {

let mut new_usage = AHashSet::default();
for id in &self.id_usage {
let mut entry = self.import_chain.remove_entry(id);
while let Some((id, next)) = entry {
new_usage.insert(next);
entry = self.import_chain.remove_entry(&id);
let mut next = self.import_chain.remove(id);
while let Some(id) = next {
next = self.import_chain.remove(&id);
new_usage.insert(id);
}
if self.import_chain.is_empty() {
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ns1 } from '../anotherFile';
import ns2 = ns1.ns2;
import Class = ns2.Class;

const a = new Class(5);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ns1 } from '../anotherFile';
const ns2 = ns1.ns2;
const Class = ns2.Class;
const a = new Class(5);

0 comments on commit 50d70d3

Please sign in to comment.