facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.07k stars 1.86k forks source link

flow-upgrade fails with transformation error #4945

Open moaazsidat opened 7 years ago

moaazsidat commented 7 years ago

Currently on flow 0.52.0 and attempting to upgrade to 0.53.0 using flow-upgrade, it fails with the following error:

ERR /path/to/my/component/Footer.js Transformation error
TypeError: Converting circular structure to JSON
    at Object.stringify (native)
    at Object.getFieldNames (/Users/msidat/.config/yarn/global/node_modules/ast-types/lib/types.js:661:22)
    at visitChildren (/Users/msidat/.config/yarn/global/node_modules/ast-types/lib/path-visitor.js:221:32)
    at Visitor.PVp.visitWithoutReset (/Users/msidat/.config/yarn/global/node_modules/ast-types/lib/path-visitor.js:202:16)
    at visitChildren (/Users/msidat/.config/yarn/global/node_modules/ast-types/lib/path-visitor.js:244:21)
    at Visitor.PVp.visitWithoutReset (/Users/msidat/.config/yarn/global/node_modules/ast-types/lib/path-visitor.js:202:16)
    at Visitor.PVp.visit (/Users/msidat/.config/yarn/global/node_modules/ast-types/lib/path-visitor.js:131:25)
    at Object.visit (/Users/msidat/.config/yarn/global/node_modules/ast-types/lib/path-visitor.js:99:51)
    at root.paths.forEach.path (/Users/msidat/.config/yarn/global/node_modules/flow-upgrade/dist/upgrades/0.53.0/ReactUtilityTypes/codemod.js:32:12)
    at Array.forEach (native)
All done.
Results:
1 errors
0 unmodified
0 skipped
0 ok

Contents of my component file Footer.js:

// @flow

const Footer = (name: string) => {
  return 'Footer' + name
}

export default Footer

any ideas on what might be going on, or how to debug this further? thanks!

sprockow commented 7 years ago

Also getting this error, though I was starting from 0.37. Like your example, there's nothing in my javascript that is particularly related to the error. I'll investigate further and post some more examples.

kelset commented 7 years ago

Same issue here, trying to upgrade frm 52 to 53 as @moaazsidat. @sprockow did you manage to find how to make it work?

kevliu commented 7 years ago

@kelset I was having the same issue. It seems to run under npx, but it doesn't complete modifying all files on a single pass.. I keep rerunning it and it modifies new files each time.