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

Macil picture Macil  路  47Comments

opensrcery picture opensrcery  路  88Comments

NgoKnows picture NgoKnows  路  40Comments

MarcoPolo picture MarcoPolo  路  67Comments

xtinec picture xtinec  路  65Comments