File tree Expand file tree Collapse file tree
packages/babel-plugin-transform-block-scoping/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,8 +75,13 @@ export default declare((api, opts: Options) => {
7575 for ( const name of names ) {
7676 if ( bodyScope ?. hasOwnBinding ( name ) ) continue ; // shadowed
7777
78+ let binding = headPath . scope . getOwnBinding ( name ) ;
79+ if ( ! binding ) {
80+ headPath . scope . crawl ( ) ;
81+ binding = headPath . scope . getOwnBinding ( name ) ;
82+ }
7883 const { usages, capturedInClosure, hasConstantViolations } =
79- getUsageInBody ( headPath . scope . getOwnBinding ( name ) , path ) ;
84+ getUsageInBody ( binding , path ) ;
8085
8186 if ( capturedInClosure ) {
8287 markNeedsBodyWrap ( ) ;
@@ -169,7 +174,9 @@ function transformBlockScopedVariable(
169174
170175 const bindingNames = Object . keys ( path . getBindingIdentifiers ( ) ) ;
171176 for ( const name of bindingNames ) {
172- path . scope . getOwnBinding ( name ) . kind = "var" ;
177+ const binding = path . scope . getOwnBinding ( name ) ;
178+ if ( ! binding ) continue ;
179+ binding . kind = "var" ;
173180 }
174181
175182 if (
You can’t perform that action at this time.
0 commit comments