File tree Expand file tree Collapse file tree
packages/babel-plugin-proposal-explicit-resource-management
transform-sync/for-head-shadow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 " babel-plugin"
1818 ],
1919 "dependencies" : {
20- "@babel/helper-plugin-utils" : " workspace:^"
20+ "@babel/helper-plugin-utils" : " workspace:^" ,
21+ "@babel/plugin-transform-destructuring" : " workspace:^"
2122 },
2223 "peerDependencies" : {
2324 "@babel/core" : " ^7.0.0-0"
Original file line number Diff line number Diff line change 11import { declare } from "@babel/helper-plugin-utils" ;
2+ import { unshiftForXStatementBody } from "@babel/plugin-transform-destructuring" ;
23import { types as t , template , traverse } from "@babel/core" ;
34import type { NodePath , Visitor , PluginPass } from "@babel/core" ;
45
@@ -51,11 +52,11 @@ export default declare(api => {
5152 left . kind = "const" ;
5253
5354 path . ensureBlock ( ) ;
54- path . node . body . body . unshift (
55+ unshiftForXStatementBody ( path , [
5556 t . variableDeclaration ( "using" , [
5657 t . variableDeclarator ( id , t . cloneNode ( tmpId ) ) ,
5758 ] ) ,
58- ) ;
59+ ] ) ;
5960 } ,
6061 "BlockStatement|StaticBlock" (
6162 path : NodePath < t . BlockStatement | t . StaticBlock > ,
Original file line number Diff line number Diff line change 1+ let log = [ ] ;
2+ {
3+ for ( using x of [ null ] ) {
4+ const x = undefined ;
5+ log . push ( x ) ;
6+ }
7+ }
8+
9+ expect ( log ) . toEqual ( [ undefined ] ) ;
Original file line number Diff line number Diff line change 1+ let log = [ ] ;
2+ {
3+ for ( using x of [ null ] ) {
4+ const x = undefined ;
5+ log . push ( x ) ;
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ let log = [ ] ;
2+ {
3+ for ( const _x of [ null ] ) try {
4+ var _usingCtx = babelHelpers . usingCtx ( ) ;
5+ const x = _usingCtx . u ( _x ) ;
6+ {
7+ const x = undefined ;
8+ log . push ( x ) ;
9+ }
10+ } catch ( _ ) {
11+ _usingCtx . e = _ ;
12+ } finally {
13+ _usingCtx . d ( ) ;
14+ }
15+ }
Original file line number Diff line number Diff line change 1414 {
1515 "path" : " ../../packages/babel-helper-plugin-utils"
1616 },
17+ {
18+ "path" : " ../../packages/babel-plugin-transform-destructuring"
19+ },
1720 {
1821 "path" : " ../../packages/babel-core"
1922 }
Original file line number Diff line number Diff line change @@ -1470,6 +1470,7 @@ __metadata:
14701470 "@babel/core": "workspace:^"
14711471 "@babel/helper-plugin-test-runner": "workspace:^"
14721472 "@babel/helper-plugin-utils": "workspace:^"
1473+ "@babel/plugin-transform-destructuring": "workspace:^"
14731474 peerDependencies:
14741475 "@babel/core": ^7.0.0-0
14751476 languageName: unknown
You can’t perform that action at this time.
0 commit comments