Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform-react-constant-elements causes "We don't know what to do with this node type." #5369

Closed
jbrantly opened this issue Feb 24, 2017 · 3 comments
Assignees
Labels
area: react Has PR outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@jbrantly
Copy link

Input Code

class A extends React.Component {
    render() {
        return <B />
    }
}

export class B extends React.Component {
    render() {
        return null
    }
}

Babel Configuration (.babelrc, package.json, cli command)

{
    "plugins": [
        "transform-react-jsx",
        "transform-react-constant-elements"
    ]
}

Expected Behavior

Should not error.

Current Behavior

Errors with "We don't know what to do with this node type. We were previously a Statement but we can't fit in here?"

Context

This seems to be a regression in 6.23.0 as the same code is transpiled into a working state with 6.22.0. My guess is that this was introduced in #5153.

Of note is that the code does transpile if the export is removed from the second class.

Your Environment

software version
Babel 6.23.0
node 6.9.4
npm 3.10.10
Operating System Windows 10

cc @STRML

@babel-bot
Copy link
Collaborator

Hey @jbrantly! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@STRML STRML self-assigned this Feb 24, 2017
@STRML
Copy link
Contributor

STRML commented Feb 24, 2017

Thanks @jbrantly, and thanks for the test case. We have a few issues we've seen in 6.23 - this is a tricky beast and includes some updates to PathHoister which are hitting a few edge cases, such as default params. I hope to have them resolved by the next minor.

@STRML
Copy link
Contributor

STRML commented Mar 3, 2017

A minimal test case:

class A {
    render() {
        return <B />
    }
}

export class B {}

The issue is that we're calling path.insertAfter() on the export class B ClassDeclaration, who's parent is an ExportNamedDeclaration, not the Program. Removing the export does not demonstrate the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: react Has PR outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

4 participants