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

TypeError: Cannot read property 'type' of null #129

Closed
roadhump opened this issue Jun 25, 2015 · 5 comments
Closed

TypeError: Cannot read property 'type' of null #129

roadhump opened this issue Jun 25, 2015 · 5 comments

Comments

@roadhump
Copy link

Got an error, probably some es7 case?

Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
    at EventEmitter.ClassProperty (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint-plugin-react/lib/rules/jsx-sort-prop-types.js:64:53)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at Controller.controller.traverse.enter (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/eslint.js:728:25)
    at Controller.__execute (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/node_modules/estraverse/estraverse.js:393:31)
    at Controller.traverse (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/node_modules/estraverse/estraverse.js:491:28)
    at EventEmitter.module.exports.api.verify (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/eslint.js:721:24)
    at processText (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/cli-engine.js:201:27)
    at CLIEngine.executeOnText (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/cli-engine.js:361:26)
    at Object.cli.execute (/Users/roadhump/Projects/Targetprocess/Mashups/ViewGallery/node_modules/eslint/lib/cli.js:179:70) 

.babelrc

{
  "stage": 0
}

Code

var React, {Component, PropTypes} = require('react');
export default class HelpTooltipsManager extends Component {

    propTypes: {
        dispatch: PropTypes.func.isRequired,
        items: PropTypes.array.isRequired,
        visibility: PropTypes.object.isRequired
    }
}
@mathieumg
Copy link
Contributor

Totally unrelated, by just out of curiosity, why do you not use the import syntax?

@yannickcr
Copy link
Member

Seems your code is not valid, it should be propTypes = instead of propTypes:.

In this case Babel do not trigger any error but it does not attach the propTypes method to the outputed class.

However, I will patch the rule to avoid the crash but I will be difficult for us to validate the propTypes order since Babel does not output much informations here.

@roadhump
Copy link
Author

@mathieumg I just rewrite my old code and some things are out of my attention, it will be import there.

@roadhump
Copy link
Author

@yannickcr thanks. I thought that if code are not valid, babel will not parse it at all.

@yannickcr
Copy link
Member

@roadhump yes, in it should not parse it, but there is a few cases were it accept invalid code (like in #125). I don't know if it can be considered as a bug or not.

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

No branches or pull requests

3 participants