Skip to content

Error did not recognize object of type "PropertyDefinition" when running update-react-imports #314

Open

Description

@julienw

I tried to run update-react-imports on our codebase https://github.com/firefox-devtools/profiler/ (commit hash e8a3afd45a8125de9c37c546f6b50c8004f122e7), and got the following error on several files:

Error: did not recognize object of type "PropertyDefinition"
    at Object.getFieldNames (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/ast-types/lib/types.js:660:19)
    at getSortedChildNodes (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:53:23)
    at getSortedChildNodes (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:62:9)
    at getSortedChildNodes (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:62:9)
    at decorateComment (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:70:22)
    at decorateComment (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:82:13)
    at decorateComment (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:82:13)
    at /home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:119:9
    at Array.forEach (<anonymous>)
    at Object.attach (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/comments.js:117:14)
    at Object.parse (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/recast/lib/parser.js:107:16)
    at fromSource (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/jscodeshift/src/core.js:82:25)
    at core (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/jscodeshift/src/core.js:44:5)
    at j (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/jscodeshift/src/core.js:142:12)
    at module.exports (/home/julien/.npm/_npx/968b6945ac80b57b/node_modules/react-codemod/transforms/update-react-imports.js:12:16)

It's not clear to me how to debug this further, but hopefully you'll be able to reproduce using code directly.

Activity

  1. julienw commented on Mar 29, 2023

    @julienw
    Author

    I must add that this worked for some files too.

  2. pascalduez commented on Jul 16, 2024

    @pascalduez

    Hello :)

    Hoping to revive this issue, especially with React 19 and the update-react-imports codemod that should gain more traction.

    I hit various errors related to "recent" Flow syntax. PropertyDefinition, but also IndexedAccessType etc.

    It might just be a matter of updating a dependency or two. Most notably ast-types.

    Please see:
    facebook/jscodeshift#478
    benjamn/ast-types#596

  3. pascalduez commented on Jul 17, 2024

    @pascalduez

    Okay, after some time to figure out the new resolutions syntax in Yarn Berry...
    I got it working with a local install and resolutions.

      "resolutions": {
        "jscodeshift": "latest",
        "ast-types": "npm:@gkz/ast-types@^0.14.4",
        "flow-parser": "0.152"
      }

    And I guess for npm:

      "overrides": {
        "jscodeshift": "latest",
        "ast-types": "npm:@gkz/ast-types",
        "flow-parser": "0.152"
      }

    Made a temporary repo to help with this issue https://github.com/pascalduez/react-codemod-patched

  4. YJ00793049 commented on Jun 18, 2026

    @YJ00793049

    This is recast/ast-types choking on newer Flow/TS syntax (PropertyDefinition, IndexedAccessType). @pascalduez's resolutions/overrides pin of ast-types + flow-parser is the right workaround — but it's brittle on a bigger codebase like the profiler.

    I've been doing these React 19 migrations end-to-end by hand — running the codemods and then fixing everything they leave broken — and getting repos to verified-green with a short confidence report. If you'd rather hand it off than babysit ast-types pins, I'm taking a few at a founding rate. Email's on my profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions