Skip to content

Rule require-default-props with Flow type definition assignment #1017

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

Closed
wyze opened this issue Jan 10, 2017 · 2 comments
Closed

Rule require-default-props with Flow type definition assignment #1017

wyze opened this issue Jan 10, 2017 · 2 comments

Comments

@wyze
Copy link
Contributor

wyze commented Jan 10, 2017

Using v6.9.0 with code like the following:

// @flow

import type { Message } from '../types'

type Props = Message

const Component = ({ message }: Props) => (
  <div>{message}</div>
)

export default Component

Crashes with:

Cannot read property 'filter' of undefined
TypeError: Cannot read property 'filter' of undefined
    at getPropTypesFromTypeAnnotation ($PWD/node_modules/eslint-plugin-react/lib/rules/require-default-props.js:178:29)
    at Object.handleStatelessComponent ($PWD/node_modules/eslint-plugin-react/lib/rules/require-default-props.js:288:42)
    at EventEmitter.updatedRuleInstructions.(anonymous function) ($PWD/node_modules/eslint-plugin-react/lib/util/Components.js:581:75)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode ($PWD/node_modules/eslint/lib/util/node-event-generator.js:39:22)
    at CodePathAnalyzer.enterNode ($PWD/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:607:23)
    at CommentEventGenerator.enterNode ($PWD/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter ($PWD/node_modules/eslint/lib/eslint.js:928:36)
    at Controller.__execute ($PWD/node_modules/estraverse/estraverse.js:397:31)

I have a fix for this, and will submit the PR shortly.

@wyze
Copy link
Contributor Author

wyze commented Jan 11, 2017

Also, in debugging this, it looks like it is not specific to importing the type. It will also throw the same error if you do something like this:

// @flow

type Message = {
  message: string,
}
type Props = Message

const Component = ({ message }: Props) => (
  <div>{message}</div>
)

export default Component

@wyze
Copy link
Contributor Author

wyze commented Feb 20, 2017

Closing as the PR to fix was merged and released in 6.10.0.

@wyze wyze closed this as completed Feb 20, 2017
@ljharb ljharb added flow and removed flow labels Jun 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants