File tree Expand file tree Collapse file tree
packages/babel-helper-create-class-features-plugin/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -195,13 +195,15 @@ function unshadow(
195195 scope : Scope ,
196196 innerBinding : t . Identifier | undefined ,
197197) {
198- const binding = scope . getBinding ( name ) ;
199- if ( innerBinding && binding && innerBinding !== binding . identifier ) {
200- // the classRef has been shadowed, rename the local variable
201- while ( ! scope . bindingIdentifierEquals ( name , innerBinding ) ) {
202- scope . rename ( name ) ;
203- scope = scope . parent ;
204- }
198+ // in some cases, scope.getBinding(name) === undefined
199+ // so we check hasBinding to avoid keeping looping
200+ // see: https://github.com/babel/babel/pull/13656#discussion_r686030715
201+ while (
202+ scope ?. hasBinding ( name ) &&
203+ ! scope . bindingIdentifierEquals ( name , innerBinding )
204+ ) {
205+ scope . rename ( name ) ;
206+ scope = scope . parent ;
205207 }
206208}
207209
You can’t perform that action at this time.
0 commit comments