jackbsteinberg / get-originals-rewriter

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Nested accessors and methods #29

Open jackbsteinberg opened 5 years ago

jackbsteinberg commented 5 years ago

Currently when the rewriter encounters nested accessors and methods it will only convert the outermost to its original:

const pathLength = url.pathname.length;
const expressionName = node.getExpression().getSymbol().getName();

---- REWRITTEN ----

const pathLength = Reflect_apply(String_length_get, url.pathName);
const expressionName = Reflect_apply(Symbol_getName, node.getExpression().getSymbol(), []);

This is possibly because parents of observed nodes are being rewritten, which prevents the algorithm from continuing to inspect and properly rewrite all the children.

domenic commented 5 years ago

Solutions discussed:

domenic commented 5 years ago

This may be more complicated than just applying the transforms recursively, because the first transform could cause a loss of type information. See https://github.com/jackbsteinberg/get-originals-rewriter/issues/35#issuecomment-522652550 for a similar issue and a proposed solution.

fergald commented 5 years ago

Reopening based on https://github.com/jackbsteinberg/get-originals-rewriter/pull/69#issuecomment-529263922