mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
011570a0785d4d2f0fd23dd5eae37ac797ce882b
This is a precursor to adding support for hoisting in semantic analysis. Previously when we encountered an unknown reference we immediately reported an error. But hoisted variables may be referenced before they're defined, so we don't know for sure when we see an unknown variable if its actually unbound or not. This PR adds the first part of hoistingn support: rather than immediately report an error when encountering an unbound variable we store it in a list of unresolved references on the current scope. As we close each scope we recheck and see if the variable can now be resolved. If yes we record that, otherwise we bubble up the unresolved reference to the parent scope (and try again there). The next PR(s) will handle hoisting of `var` and other syntax to the apropriate nearest scope boundary (function/module).
Description
Languages
JavaScript
67.1%
TypeScript
29.4%
HTML
1.5%
CSS
1.1%
C++
0.6%
Other
0.2%