Comments (1)
I'm working on this (and also decaffeinate/decaffeinate#605 ), and it turns out to be a pretty significant change to this project, so I guess I'll write down some notes of my plan in case I'm overlooking a better way:
- Rather than ever doing magic-string operations while traversing the tree, the new plan is to maintain tentative information about all bindings, which might change as we discover more information, and then only "commit" those bindings at the end (or, at least, when we know they won't change anymore).
- Each of these tentative binding objects is "owned" by some function (or program) scope (really some TraverseState with a function scope), even if we end up adding the
var
in a more specific scope. That means we won't miss declarations withinif
statements (fixing decaffeinate/decaffeinate#605 ) and lets us know that two variables are the same for the purpose of finding the most specific scope. - As we see variable declarations and usages, we traverse up to the enclosing function scope to find the latest binding information, then update the "most specific scope" information to the lowest common ancestor of the two.
- In cases where we'd prefer to do an inline declaration (e.g. a destructure), we only end up doing so if none of the assigned variables ended up moving to a parent scope.
from add-variable-declarations.
Related Issues (20)
- donβt use var HOT 1
- An in-range update of @types/node is breaking the build π¨ HOT 38
- An in-range update of @types/jest is breaking the build π¨ HOT 7
- An in-range update of ts-jest is breaking the build π¨ HOT 1
- An in-range update of magic-string is breaking the build π¨ HOT 1
- An in-range update of babel7 is breaking the build π¨ HOT 1
- An in-range update of babel7 is breaking the build π¨ HOT 2
- An in-range update of babel7 is breaking the build π¨ HOT 18
- The automated release is failing π¨ HOT 1
- Dependency Dashboard
- Move to babylon for JS parsing HOT 1
- Assign-after-reference should not assume global HOT 1
- Not handling node type WhileStatement
- An in-range update of babylon is breaking the build π¨ HOT 2
- An in-range update of babel-types is breaking the build π¨
- An in-range update of babel-traverse is breaking the build π¨
- The automated release is failing π¨ HOT 2
- An in-range update of babel7 is breaking the build π¨ HOT 19
- An in-range update of @types/babel__traverse is breaking the build π¨ HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from add-variable-declarations.