Skip to content

Destructuring assignment

This implements support for destructuring assignment. The way I use magic-string can probably use a review and some suggestions — I was having a hard time getting things to appear in the right order, so I ended up doing something that's maybe not quite in the spirit of the library.

The implementation takes care to leave destructuring assignments as expressions, turning them into a series of assignments separated by commas. It allocates scratch variables when needed (though it isn't entirely optimal in avoiding them -- if that's considered problematic enough to warrant more code complexity, let me know). The way it places those is somewhat problematic (before the parent statement), but the same problem exists in other scratch-variable-allocating transpile methods.

Looking forward to your feedback.

Merge request reports