Debian Codegraph @

packages/babel-plugin-transform-block-scoping/test/fixtures/general/issue-10339/exec.js

raw symbols SCIP
1 const code = `
2 for (const {foo, ...bar} of { bar: [] }) {
3 () => foo;
4 const [qux] = bar;
5 try {} catch (e) {
6 let quux = qux;
7 }
8 }
9 `;
10
11 let programPath;
12 let forOfPath;
13 let functionPath;
14
15 return transformAsync(code, {
16 configFile: false,
17 plugins: [
18 __dirname + "/../../../../lib/index.js",
19 {
20 post({ path }) {
21 programPath = path;
22 path.traverse({
23 ForOfStatement(path) { forOfPath = path },
24 FunctionExpression(path) { functionPath = path }
25 });
26 }
27 }
28 ]
29 }).then(() => {
30 expect(Object.keys(programPath.scope.bindings)).toEqual(["foo", "bar"]);
31
32 // for declarations should be transformed to for bindings
33 expect(forOfPath.scope.bindings).toEqual({});
34 // The body should be wrapped into closure
35 expect(forOfPath.get("body").scope.bindings).toEqual({});
36
37 expect(Object.keys(functionPath.scope.bindings)).toEqual(["foo", "qux", "quux"]);
38 });