You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
Output: 1, 2
Untranspiled code works as expected for example in latest Chrome.
Actual behavior:
Output: 1, undefined
The destructuring is transpiled to (foo = foo.foo, bar = foo.bar);. After assigning foo the access of foo.bar yields undefined.
In such cases (possibly in all cases) there is the need for an intermediate variable that stores the destructured object (or array).
Reacted by Asad Saeeduddin, Ghabriel Nunes, Aluan Haddad and Geir Sagberg
Had this same issue today when converting a project from Babel to TypeScript, In Babel it works as expected, but TypeScript (2.6.2) has the bug mentioned above.
Activity
geirsagberg commentedon Dec 11, 2017
Had this same issue today when converting a project from Babel to TypeScript, In Babel it works as expected, but TypeScript (2.6.2) has the bug mentioned above.
Babel produces this:
However, if changing the code to:
Then babel produces:
So it is obvious some kind of detection is being done here, and TypeScript should do this as well.