I stumped on something in Typescript today.

What does the three dots mean in this type?
I can't find anything that explain this at all.
I'm trying to do something like this
let all: { readonly [key: string]: (...args: any) => any } = {
form,
metadatas_reducer,
loader_reducer
}
const combinedReducer = combineReducers(all)
This is the TypeScript spread operator: https://howtodoinjava.com/typescript/spread-operator/
Which can also destructure incoming arrays and dictionaries, so you can merge two dictionaries by doing this:
> a = [1,2,3]
[ 1, 2, 3 ]
> b = [4,5,6]
[ 4, 5, 6 ]
> [a,b]
[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
> [...a,...b]
[ 1, 2, 3, 4, 5, 6 ]
VSCode will sometimes replace types with an ellipse for some reason, possibly to shorten them. In this specific case, the build output is the following.
export declare const combinedReducer: import("redux").Reducer<import("redux").CombinedState<{
readonly [x: string]: any;
}>, import("redux").AnyAction>;
This is not the spread operator.
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