Flow: Did you forget to declare type parameter `DefaultProps` of identifier `Component`

Created on 26 Jan 2017  路  2Comments  路  Source: facebook/flow

Whenever I use

MyComponent.defaultProps = {
    ...something
}

after MyComponent is created by

class MyComponent extends Component {
    ...
}

flow gives the error:

object literal. This type is incompatible with undefined
Did you forget to declare type parameter `DefaultProps` of identifier `Component`

Most helpful comment

This is type error. Flow has already inferred the type for your class before you try to mutate the defaultProps property.

And since you didn't give it a type it was inferred as void.

class MyComponent extends Component {
    static defaultProps: Object;
}

This should fix it.

All 2 comments

This is a bug I would say... suffering the same here at the moment

This is type error. Flow has already inferred the type for your class before you try to mutate the defaultProps property.

And since you didn't give it a type it was inferred as void.

class MyComponent extends Component {
    static defaultProps: Object;
}

This should fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bennoleslie picture bennoleslie  路  3Comments

jamiebuilds picture jamiebuilds  路  3Comments

john-gold picture john-gold  路  3Comments

glenjamin picture glenjamin  路  3Comments

funtaps picture funtaps  路  3Comments