I am reading ngrx docs and stumbled upon such a code. What do [p in keyof T]
and T[p]
mean?
export type ActionReducerMap<T, V extends Action = Action> = {
[p in keyof T]: ActionReducer<T[p], V>
};
That is a mapped type. You can read about them in the typescript docs here, or in this blog post.
Basically, the syntax [p in keyof T]
means just that; p
is one of the keys of the object T
. Then, the T[p]
just represents the type of that key's value. Read those two links for a more robust explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With