Reputation: 583
In facebooks flux-utils example, they do something like this:
import {ReduceStore} from 'flux/utils';
class CounterStore extends ReduceStore<number> {
getInitialState(): number {
return 0;
}
reduce(state: number, action: Object): number {
switch (action.type) {
case 'increment':
return state + 1;
case 'square':
return state * state;
default:
return state;
}
}
}
Can anyone tell me what the <number>
angle brackets next to ReduceStore
does in JS?
I tried to look this up but don't really know what this es6 feature is called...
Thanks to anyone that helps!
Upvotes: 0
Views: 91
Reputation: 57954
It isn't an ES6 feature, it's part of Flow, a static typechecker for your ES6 code. It's sort of like TypeScript in the sense it adds new syntax though they have their substantial differences (TypeScript is full-fledged language). Flow uses Babel to transpile your type annotations to pure ES6.
Upvotes: 5