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

Support Flow Prop/State syntax #453

Closed
mmermerkaya opened this issue Feb 18, 2016 · 7 comments · Fixed by #1377
Closed

Support Flow Prop/State syntax #453

mmermerkaya opened this issue Feb 18, 2016 · 7 comments · Fixed by #1377

Comments

@mmermerkaya
Copy link

Is it possible for you to support this:
class MyComponent extends React.Component<void, Props, void> {

which does the same thing as this:

class MyComponent extends React.Component {
  props: Props

Also described here.

@ljharb
Copy link
Member

ljharb commented Feb 18, 2016

See facebook/react#1833 (comment) - propTypes aren't going anywhere.

@mmermerkaya
Copy link
Author

I know, I just linked the thread because someone working on React provided an example of declaring props using Flow.

Edit: Apparently the comment you linked to is also written by the same person.

@yannickcr
Copy link
Member

We already support flow annotations for props (see #382) but not the syntax you described.

I do not know Flow very well (I do not use it), but maybe adding support for this will not be very difficult.

@MoOx
Copy link
Contributor

MoOx commented Mar 25, 2016

With babel-eslint, it seems to be working fine.

@jamiebuilds
Copy link

Should eslint-plugin-react add babel-eslint somehow to people's configs? Seems pretty standard in the React community

@ljharb
Copy link
Member

ljharb commented Aug 3, 2016

Requiring babel-eslint means it has to be a peer dependency, so that would add some burden on everyone wishing to use the plugin.

However, if we want rules that support flow types, it's possible we might need to require that parser.

phpnode added a commit to codemix/eslint-plugin-react that referenced this issue Apr 3, 2017
This adds support for constructions like this:

    type Props = {name: string};
    class X extends React.Component<void, Props, void> {
      ...
    }

Which is the preferred way to declare prop types using Flow.

The less preferred syntax is still supported:

    class Z extends React.Component {
      props: Props;
    }

Fixes jsx-eslint#453
phpnode added a commit to codemix/eslint-plugin-react that referenced this issue Apr 3, 2017
This adds support for constructions like this:

    type Props = {name: string};
    class X extends React.Component<void, Props, void> {
      ...
    }

Which is the preferred way to declare prop types using Flow.

The less preferred syntax is still supported:

    class Z extends React.Component {
      props: Props;
    }

Fixes jsx-eslint#453
@ljharb ljharb added the flow label Jun 13, 2017
@jomasti
Copy link
Contributor

jomasti commented Jan 5, 2019

I believe this was resolved by #1377.

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

Successfully merging a pull request may close this issue.

6 participants