Skip to content

Commit e16ae27

Browse files
committed
fix: printUse
1 parent 51cb49e commit e16ae27

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

packages/transpiler/src/nodes.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,14 @@ export class Printer {
698698
}
699699
break;
700700
}
701+
case "identifier": {
702+
const name = item.text;
703+
yield [`import * as ${name} from "${name}";\n`, item.startPosition];
704+
break;
705+
}
701706
case "use_as_clause": {
702707
const original = item.namedChildren[0];
703-
yield* this.printUseItem(original, "", alias);
708+
yield* this.printUseItem(original, base, alias);
704709
break;
705710
}
706711
case "use_wildcard": {
@@ -736,7 +741,7 @@ export class Printer {
736741
return path.text;
737742
}
738743
else if (path.type === "scoped_identifier") {
739-
return path.namedChildren[1].text;
744+
return getSelfName(path.namedChildren[1]);
740745
}
741746
else if (path.type === "crate") {
742747
return "crate";

packages/transpiler/test/fixtures/basic.jsrs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub use crate::x::{x::y::{self, y1, y2}, z::self as t, t as h};
22
pub use t::x;
33
pub use s::*;
4+
pub use r;
45

56
pub fn add(a: i32, b: i32) -> i32 {
67
a + b

packages/transpiler/test/snapshots/basic.do.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { y, y1, y2, t, h };
77
import { x } from "t";
88
export { x };
99
export * from "s";
10+
import * as r from "r";
1011
export function add(a, b) {
1112
return a + b;
1213
}

packages/transpiler/test/snapshots/basic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { y, y1, y2, t, h };
77
import { x } from "t";
88
export { x };
99
export * from "s";
10+
import * as r from "r";
1011
export function add(a, b) {
1112
return a + b;
1213
}

0 commit comments

Comments
 (0)