Reputation: 3292
I'm trying to create an es6 class with flow type checking:
/* @flow */
export default class ListHolder<Tv> {
getList = (): Array<Tv> => {
return [];
};
iterateOverList = (): mixed => {
return this.getList().map((item: mixed, index: number) => {
// no-op
return null;
});
};
}
The problem is that I keep getting a flow error that Tv [1] is incompatible with Tv [1].
referencing the line getList = (): Array<Tv> => {
. Can someone help me understand this error?
It resolves if I comment out the map
invocation, but I haven't been able to make much progress beyond that and the error messages aren't particularly helpful.
Thanks,
Upvotes: 0
Views: 89
Reputation: 24241
Looks like your creating a class, but assigning methods to a class is not done using assignment operator. =
and arrow functions =>
.
I think this is more what your after. ->
/* @flow */
export default class ListHolder<Tv> {
getList (): Array<Tv> {
return [];
};
iterateOverList (): mixed {
return this.getList().map((item: mixed, index: number) => {
// no-op
return null;
});
};
}
Upvotes: 1