Skip to content

Commit

Permalink
Register var decls generated by import ... = TS transform (#15489)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
  • Loading branch information
amoeller and nicolo-ribaudo committed Mar 14, 2023
1 parent 4035521 commit 98c6d63
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/babel-plugin-transform-typescript/src/index.ts
Expand Up @@ -595,6 +595,7 @@ export default declare((api, opts: Options) => {
),
]),
);
path.scope.registerDeclaration(path);
},

TSExportAssignment(path) {
Expand Down
@@ -0,0 +1 @@
import foo = bar
@@ -0,0 +1,3 @@
{
"plugins": ["transform-typescript", "./plugin"]
}
@@ -0,0 +1 @@
var foo = bar;
@@ -0,0 +1,16 @@
module.exports = function({ types: t }) {
return {
visitor: {
Identifier(path) {
if (path.node.name === "foo") {
expect(path.scope.hasBinding(path.node.name)).toBe(true);
}
},
Program: {
exit() {
expect.hasAssertions();
}
}
}
};
};

0 comments on commit 98c6d63

Please sign in to comment.