codemodsquad / astx

Super powerful structural search and replace for JavaScript and TypeScript to automate your refactoring
MIT License
92 stars 6 forks source link

Distributed app looks to have incorrect compilation #4

Closed danielo515 closed 3 years ago

danielo515 commented 3 years ago

Hello. Thanks for this great project. I noticed that the compiled output of this package has a problem on it. Despite it is using the requireInterop helper, it still tries to access the default exported property, which is not required:

// getfieldNames.js
function addFieldNames(type) {
  var fieldNames = _astTypes["default"].getFieldNames({
    type: type
  });

That throws an exception because prop default does not exist. I tested on node 14. Changing it to this makes it work:

// getfieldNames.js
function addFieldNames(type) {
  var fieldNames = _astTypes.getFieldNames({
    type: type
  });
jedwards1211 commented 3 years ago

Huh that's odd, I couldn't reproduce it, as interopRequireDefault creates an object with a default property as far as I can tell. But, I had an old version of @types/jscodeshift that was pulling in a different version of ast-types, so I don't doubt there was some issue...I went ahead and changed all those statements to import * as t from 'ast-types'. There should be a release once CI passes!

jedwards1211 commented 3 years ago

:tada: This issue has been resolved in version 1.2.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: